resize and upload image problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Here is my script. The file is not uploading. In my orignal script it is 
$_FILES['userfile']['tmp_name'][$i]; that gets uploaded as I have an array 
of images and it loops through. It must be something to do with this line

$tmpName = imagecopyresampled($image_resized, $image, 0, 0, 0, 0, 
$new_width, $new_height, $width, $height);


that breaks it.




---------------------------------------------

$total= count($_FILES['userfile']['name']);

for ($i=0; $i <$total; $i++) {

$fileName = $_FILES['userfile']['name'][$i];
$tmpName  = $_FILES['userfile']['tmp_name'][$i];
$fileSize = $_FILES['userfile']['size'][$i];
$fileType = $_FILES['userfile']['type'][$i];
$image = imagecreatefromjpeg($tmpName);
if ($image === false) { exit; }
Get original width and height
echo $width = imagesx($image);
echo  $height = imagesy($image);

// New width and height
$new_width = 200;
 $new_height = 150;

// Resample
$image_resized = imagecreatetruecolor($new_width, $new_height);
$tmpName = imagecopyresampled($image_resized, $image, 0, 0, 0, 0, 
$new_width, $new_height, $width, $height);

$position=$i+1;

$img_url = $_SERVER['DOCUMENT_ROOT']."/images/$customer_id/". basename( 
$_FILES['userfile']['name'][$i]);

//$img_url=  $target_path . basename( $_FILES['userfile']['name'][$i]);

if(move_uploaded_file($tmpName, $img_url)) {
chmod('images/'.$customer_id, 0777);

 chmod($img_url, 0777);

}



} 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux