Jump to content

resize image then upload, doestn work need help !


oz_gr

Recommended Posts

Hi; i m using the following code for multiple upload processes ; what i want to achieve is resize larger images like 7, 10 MP files which aer 3 4 MB to smaller size; like 800*600 i have tried almost almost everything from GD library to some scripts i found on web! any help will be appreciated. Regards

 

======================= Code =============================

 

$numoffiles = 5;

echo '<form method="post" action="'.$_SERVER['PHP_SELF'].'" enctype="multipart/form-data">' ;

for ($i = 1; $i<=$numoffiles; $i++)

{

echo 'Image'.$i.': <input type="file" name="file[]" size="30" style="cursor:hand;"/> <br /> ';

}

echo '<input type="submit" name="action" value="Upload" />';

echo '</form>';

 

if(isset($_POST['action']))

{

$uploaddir = 'uploads/';

for ($i =0; $i<$numoffiles; $i++)

{

$filename = $_FILES['file']['name'][$i];

$filetmp = $_FILES['file']['tmp_name'][$i];

$filesize = $_FILES['file']['size'][$i];

$filetype = $_FILES['file']['type'][$i];

$ext = substr(strrchr($filename, "."),1);

$conf = $uploaddir . $filename;

$filepath = $uploaddir . $filename;

$pic[$i]=$filename;

resize($fiename, 640, $filetmp);

 

 

 

 

if ($filename != "")

{

 

if (!file_exists($filepath))

{

if ($ext == "jpg" || $ext == "gif" || $ext == "tiff" || $ext == "png" || $ext == "bmp")

{

if($filesize < "2048000")

{

$upload = move_uploaded_file($filetmp, $filepath);

echo '<font color=blue>'. $filename . ' <i>was successfully uploaded...</font><br />';

echo $pic[$i];

}

else

{

echo '<font color=red>'.$filename . ' <i>greater than the maximum file size allowed...</font><br />';

}

}

else

{

echo '<font color=red>'. $filename . ' <i>is invalid file type...</font><br />';

}

}

else

{

echo $filename . ' <i>already exists...</i><br />';

}

}

 

}

}

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.