hi all

i have wrote a code for file uploader and it was working fine but now its getting sme problems...here am attaching my code plz check it out and replay me fast...

if ($_FILES["description"]["error"] > 0)
        {
        echo "Return Code: " . $_FILES["description"]["error"] . "<br />";
        }
          else
        {
   if (file_exists("/upload/" . $_FILES["description"]["name"]))
   {
           move_uploaded_file($_FILES["description"]["tmp_name"], "/upload/" . $_FILES["description"]["name"]);
           echo "Your description has been uploaded: " . "upload/" . $_FILES["description"]["name"];
           echo $_FILES["description"]["name"] . "already exists.";
   }
   else
   {
        move_uploaded_file($_FILES["description"]["tmp_name"], "/upload/" . $_FILES["description"]["name"]);
        echo "Your description has been uploaded: " . "/upload/" . $_FILES["description"]["name"];
   }
   $des="/upload/" . $_FILES['description']['name'];   
}

i have wrote a code for file uploader and it was working fine but now its getting sme problems...

Be specific. What problem exactly ?
P.S Please use [code] tags next time you post your code.

its showing some warning message...like

Warning: move_uploaded_file(/upload/1-p1.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in C:\webs\photo.php on line 36

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\WINDOWS\php157.tmp' to '/upload/1-p1.jpg' in C:\webs\photo.php on line 36
Your description has been uploaded: /upload/1-p1.jpg

Check if you have a path for the temp directory in upload_tmp_dir in php.ini , you have all the permissions for that folder. Your code seems ok to me. But, in this part, it will check if the file already exists. If it does, then you are overwriting the original file and then displaying the message 'file already exists'. :S

if (file_exists("/upload/" . $_FILES["description"]["name"]))
{
move_uploaded_file($_FILES["description"]["tmp_name"], "/upload/" . $_FILES["description"]["name"]);
echo "Your description has been uploaded: " . "upload/" . $_FILES["description"]["name"];
echo $_FILES["description"]["name"] . "already exists.";
}
else
{
move_uploaded_file($_FILES["description"]["tmp_name"], "/upload/" . $_FILES["description"]["name"]);
echo "Your description has been uploaded: " . "/upload/" . $_FILES["description"]["name"];
}

The code is working in localhost but in the web server it is not working while hosting the file its not moving to the specified folder in to the server.All the message is coming like image already move to the folder but its not storing to the folder...

Open your php.ini file and look for "File Uploads". Check upload_tmp_dir path. If there isn't any, specify the path. Restart web server and try again !

Actually i have hosted the site in websever ie through hostcats and we registered the complaint that the file uploading is not working for the above code.But tey are telling that is the problem with the code , Iam not getting any problem in the code.Can anybody rectify the problem..just reply me..Its working fine in localhost am using apache as localserver.

then try giving the path like
/home/wesitname/public_html/folder....
the path should start as /home/website then the location where u want to store

This article has been dead for over six months. Start a new discussion instead.