I'm testing an image upload on wampserver2 and getting these errors:

Warning: move_uploaded_file(../uploads/test.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in C:\wamp\www\upload_image.php on line 28

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\wamp\tmp\php8F47.tmp' to '../uploads/test.jpg' in C:\wamp\www\upload_image.php on line 28

The below is the code that it is refering to:

if (move_uploaded_file ($_FILES['upload']['tmp_name'], "/images/{$_FILES['upload']['name']}")) {
echo '<p><em>The file has been uploaded!</em></p>';
}

I'm on windows vista and I have full control on my folders images and tmp.

    on windows /images/ should be \images\

      Actually, I believe PHP is able to deal with forward slashes on a Windows machine. However, you are moveing the file to a file-system path, so "/images/" is not an "images" directory right under the web root directory, but is interpreted as a (non-existent) absolute file-system path. What I'm guessing you probably want is:

      if (move_uploaded_file ($_FILES['upload']['tmp_name'], 
          $_SERVER['DOCUMENT_ROOT']."/images/{$_FILES['upload']['name']}")) {
      
        NogDog wrote:

        Actually, I believe PHP is able to deal with forward slashes on a Windows machine. However, you are moveing the file to a file-system path, so "/images/" is not an "images" directory right under the web root directory, but is interpreted as a (non-existent) absolute file-system path. What I'm guessing you probably want is:

        if (move_uploaded_file ($_FILES['upload']['tmp_name'], 
            $_SERVER['DOCUMENT_ROOT']."/images/{$_FILES['upload']['name']}")) {
        

        Many thanks for the help.

          Write a Reply...