Can someone here better explain move_uploaded_file? Expecially the part where your telling where to upload the file to on the server. I have problems uploading files. I'm pretty sure I got the source file location part coded correctly. Its the destination file location part thats giving me the problems. I was using copy to upload files. The script would start to upload the file and then I would get an error saying can't open_basedir, file in wrong directory. I want to use move_uploaded file instead to upload files. I have looked at the manual but I just need a little bit better explaination.

Thanks in advance for any help I get.

    Anthony,

    Please post the script and exact error message you were using with copy. Here are some things I'd check out:

    1. Are you using the full path from root to copy to?
    2. You most likely need to be running the script as yourself. i.e. not as the "www" user. This is usually done using a wrapper, check and see if your host has one.
    3. Is the file huge? You said it stops halfway, which sounds like a timeout. Most servers won't let a script run for more than 30 seconds (to stop run-away scripts), and it's running the entire time it's uploading.

    Let me know if this helps, and if you post more info I can help more.

    Peace,
    Tom

      move_uploaded_file doesn't actually handle the uploading of the file it, as the name implies, moves the file after it has been uploaded. Here's a snip of code:

      if (is_uploaded_file($file)) 
      {
        move_uploaded_file($file, "$path/$file_name");
      }
      

      The above script assumes you have register globals on, if you have a newer version of PHP it most likely isn't so you will have to use $FILES. For more information on uploads and what is available in $FILES look here
      http://www.php.net/manual/en/features.file-upload.php

        PHP manual has a whole section made for Uploading files(multiple as well)..

        Good to know that you found Safe Mode on...

          Do I have to include the full path on the server where the files should be uploaded to? I think that may be the problem. The form itself is done correctly. Can someone give an example of how to include the full path? Heres my code for the copy. It does upload the file.

          copy ($imagefilename, $imageuploc);

          I do know that safe mode is turned on. Heres the error message I get.

          Warning: open_basedir restriction in effect. File is in wrong directory

            How do you strip the path out of a veriable so you'll have just the filename? I've tried what the manual says but thats not helping to much.

              Your error says it. Safe Mode is on. I do know. Cos i am hosted by the same person. You cannot use copy();

                What are you using to upload files? I know you got an upload file feature for you site.

                  Write a Reply...