0

I get this error and I am not sure how to clear it. Not sure if its on my WAMP and if so I have two ini file, development and production, where should I look?

( ! ) Warning: move_uploaded_file(uploadedFiles/gal2.jpg): failed to open stream: No such file or directory in C:\wamp\www\fileupload.php on line 20
Call Stack
#   Time    Memory  Function    Location
1   0.0007  257960  {main}( )   ..\fileupload.php:0
2   0.0015  303448  move_uploaded_file ( )  ..\fileupload.php:20

( ! ) Warning: move_uploaded_file(): Unable to move 'C:\wamp\tmp\php71A.tmp' to 'uploadedFiles/gal2.jpg' in C:\wamp\www\fileupload.php on line 20
Call Stack
#   Time    Memory  Function    Location
1   0.0007  257960  {main}( )   ..\fileupload.php:0
2   0.0015  303448  move_uploaded_file ( )  ..\fileupload.php:20

The code is below:

$desiredPath = 'uploadedFiles/';
if ($_SERVER['REQUEST_METHOD'] == "POST")
{
    print "Picture Info"."<br>";
    print_r($_FILES['picture']);

    if (move_uploaded_file($_FILES['picture']['tmp_name'], $desiredPath.$_FILES['picture']['name']))
    {
        print 'File Upload Successful';
        print '<div>';
        print '<img width="300px" src="'.$desiredPath.$_FILES['picture']['name'].'">';
        print '</div>';
    }
    else
    {
        print 'File Upload Failed with error code: '.$_FILES['picture']['error'];
    }
}
1
  • Make sure the folder has proper write permissions. Either 0755 or 0777. Also make sure that your folder is indeed named uploadedFiles and not uploadedfiles. It matters on UNIX/LINUX systems. Commented Oct 5, 2013 at 15:40

1 Answer 1

1

Your code:

$desiredPath = 'uploadedFiles/';

Have you tested that the directory exists, before moving the file to it? Code below:

if(!file_exists($desiredPath)) {
    mkdir($desiredPath, 0755, true);
}

It's just a suggestion. I was trying to create an upload script myself and that little block of code solved all my problems

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.