Jump to content

Upload directory problem


xgd

Recommended Posts

Hi all.

 

i am trying out this script with which i am suppoused to upload a text file to a destination directory, but am having trouble with the destination directory. I have made a directiry called "uploads" in my root folder, and the part of the code is :

 

.....

// put the file where i want it

  $upfile = '/uploads/'.$_FILES['userfile']['name'];

 

  if (is_uploaded_file($_FILES['userfile']['tmp_name']))

  {

    if (!move_uploaded_file($_FILES['userfile']['tmp_name'], $upfile))

    {

        echo 'Problem: Could not move file to destination directory';

        exit;

    }

  }

  else

......

 

But every time i try to upload the file it says the directory doesnt exist or smth like that. "failed to open stream". Everything else works, the problem is in the folder, but i cant figure out whats wrong.

 

What do you guys think ? Help please.

Link to comment
https://forums.phpfreaks.com/topic/128716-upload-directory-problem/
Share on other sites

Sorry for not using code].

 

I tried what you both said, it didnt work. I get this warning below the first one as well (i'm testing locally).

 

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:/Documents and Settings/voja/Desktop/EasyPHP 2.0b1\tmp\phpDF.tmp' to '../uploads/testfile.txt' in C:\Documents and Settings\voja\Desktop\EasyPHP 2.0b1\www\upload.php on line 34
Problem: Could not move file to destination directory

 

Maybe you can find the problem from that ?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.