|
|
|
php resize rename and upload convert to gif format |
|
|
|
|
|
|
|
ถ้าเราจะรีเนมชื่อให้เป็นชื่อตาม session_id และเซฟเป็น .gif และก็ resize ด้วยจะต้องทำยังไงคะ
Code (PHP)
<?php
session_start();
$session_id='1'; //$session id
$path = "uploads/";
$valid_formats = array("jpg", "png", "gif", "bmp");
if(isset($_POST) and $_SERVER['REQUEST_METHOD'] == "POST")
{
$name = $_FILES['photoimg']['name'];
$size = $_FILES['photoimg']['size'];
if(strlen($name))
{
list($txt, $ext) = explode(".", $name);
if(in_array($ext,$valid_formats))
{
if($size<(1024*1024))
{
$actual_image_name = time().substr(str_replace(" ", "_", $txt), 5).".".$ext;
$tmp = $_FILES['photoimg']['tmp_name'];
if(move_uploaded_file($tmp, $path.$actual_image_name))
{
echo "<img src='uploads/".$actual_image_name."' class='preview'>";
}
else
echo "failed";
}
else
echo "Image file size max 1 MB";
}
else
echo "Invalid file format..";
}
else
echo "Please select image..!";
exit;
}
?>
Tag : PHP
|
|
|
|
|
|
Date :
2013-07-01 13:20:48 |
By :
123 |
View :
982 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
รีเนมเซฟเป็น gif เช่น 000.gif
|
|
|
|
|
Date :
2013-07-01 14:07:25 |
By :
123 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|