Upload photos -- keeps not responding
Posted: Thu Aug 07, 2008 8:24 pm
OK, I'm making a page that you upload photos and then it resizes them and sticks them on the server. The code works half the time. When it doesn't work it just sits there as if it's still loading, but will never stop.
Here's the code
I did make a php.ini file with: ini_set("upload_max_filesize", "2000000000");
Also, it seems to always work on firefox, but working half the time in Safari.
=/
Any ideas?
Here's the code
Code: Select all
<?
$uploadd = $HTTP_POST_VARS['uploadd'];
echo "up: $uploadd :";
$uploaddir = '../../images/trucks/';
$num = (rand()%10000);
$imageName=$num . $_FILES['attachment']['name'];
$uploadfile = $uploaddir . $imageName;
echo "trying, $uploadfile <br>";
if (move_uploaded_file($_FILES['attachment']['tmp_name'], $uploadfile)) {
echo "it's moved..";
///resize image
// Get new sizes
list($width, $height) = getimagesize($uploadfile);
$newwidth = 500;
$newheight = $height * ($newwidth/$width);
// Load
$thumb = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefromjpeg($uploadfile);
// Resize
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
// Output
imagejpeg($thumb, $uploadfile);
echo "MOVED FIRST";
$img_size = GetImageSize($uploadfile);
$Width = $img_size[0];
$Height = $img_size[1];
echo "Check server for photo!!";
$images=$images.$imageName."`";
}
$i=0;
$keepgoing=true;
while($keepgoing){
$i++;
$fl="attachment$i";
echo ":: $fl";
if($_FILES["$fl"]){
echo "NEW FILE";
$num = (rand()%10000);
$imageName=$num . $_FILES["$fl"]['name'];
$uploadfile = $uploaddir . $imageName;
//$uploadfile = $uploaddir . $num . $_FILES["$fl"]['name'];
if (move_uploaded_file($_FILES["$fl"]['tmp_name'], $uploadfile)) {
$img_size = GetImageSize($uploadfile);
$Width = $img_size[0];
$Height = $img_size[1];
$images=$images.$imageName."`";
}
echo "images:$images";
}else{
$keepgoing=false;
return;
}
}
?>Also, it seems to always work on firefox, but working half the time in Safari.
=/
Any ideas?