Jump to content

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 ?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.