Problem uploading image
Posted: Thu Jun 04, 2009 5:33 am
Hello,
I have just transfered my webpage to another server, and now the script that uploads an image file doesnt work. All i get is the "Sorry, there was a problem uploading your file." from when the image fails to trasfer.
What might be the source of the problem?
Here is the script
I have just transfered my webpage to another server, and now the script that uploads an image file doesnt work. All i get is the "Sorry, there was a problem uploading your file." from when the image fails to trasfer.
What might be the source of the problem?
Here is the script
Code: Select all
$rand1 = rand();
$target = dirname( __FILE__ )."photos/";
$target1 = $target . $rand1 . basename( $_FILES['photo1']['name']);
if (($_FILES['photo1']['name']) == ""){
$pic1="default.gif";
}
else{
$pic1 = $rand1 . basename( $_FILES['photo1']['name']);
if (!getimagesize($_FILES['photo1']['tmp_name'])){
echo "Invalid Image File...";
exit();
}
}
$name = $_REQUEST['name'];
$telephone = $_REQUEST['telephone'];
$address = $_REQUEST['address'];
$lat = $_REQUEST['lat'];
$lng = $_REQUEST['lng'];
$date=time();
if (($_FILES['photo1']['name']) != ""){
//Writes the photo to the server
if(move_uploaded_file($_FILES['photo1']['tmp_name'], $target1))
{
//Tells you if its all ok
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory";
//create thumbanail
$n_width=100; // thumbanil width
$n_height=100; // thumbnail height
$thumbs = "thumbnails/";
$thumbs = $thumbs . $rand1 . basename( $_FILES['photo1']['name']);
//if($_FILES['photo1'][type]=="image/jpeg"){
$im=ImageCreateFromJPEG($target1);
$width=ImageSx($im); // Original picture width is stored
$height=ImageSy($im); // Original picture height is stored
$newimage=imagecreatetruecolor($n_width,$n_height);
imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
ImageJpeg($newimage,$thumbs);
//chmod("$thumbs",0777);
//}
// end thumbnail creation
}
else {
//Gives and error if its not
echo "Sorry, there was a problem uploading your file.";
}
}