Hi
I'm having some problem in uploading an image to a directory. Once I sort that I will then reference it in the database but for now I'm just trying to get the image to be saved on our server. The problem is when I try and move the temp image the code dies with the error message "could not move file" but does not display an error.
I've tried a relative path and a full path and neither work.
Echoing the image details works.
Copying the address from the echoed line and pasting it into the address bar works so I know that's right.
I have the following code:
<?php
session_start();
//if ($_POST['upload_file'] == "")
//{
//die ("There was no file entered to upload");
//}
if ((($_FILES['upload_file']['type'] == "image/gif") ||
($_FILES['upload_file']['type'] == "image/jpeg") ||
($_FILES['upload_file']['type'] == "image/pjpeg")) &&
($_FILES['upload_file']['size'] < "3145728"))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Error: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["upload_file"]["name"] . "<br />";
echo "Type: " . $_FILES["upload_file"]["type"] . "<br />";
echo "Size: " . ($_FILES["upload_file"]["size"] / 1024) . " Kb<br />";
echo "Stored in: " . $_FILES["upload_file"]["tmp_name"];
if (file_exists("/New Site/Images/Users Gallery/" . $_FILES["upload_file"]["name"]))
{
echo $_FILES["upload_file"]["name"] . " already exists. ";
}
else
{
echo "<br>".$_FILES["upload_file"]["tmp_name"]."/New%20Site/Images/Users%20Gallery/".$_FILES["upload_file"]["name"];
move_uploaded_file($_FILES["upload_file"]["tmp_name"],"/New%20Site/Images/Users%20Gallery/".$_FILES["upload_file"]["name"])or die("could not move file".mysql_error());
echo "Now stored in: " . "/New Site/Images/Users Gallery/" . $_FILES["upload_file"]["name"];
} //end if file exists
} //end if error > 0
}
else //else for if a jpeg or gif
{
echo "Error, the file must be a gif or jpeg";
}
?>