Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Mar 2007
    Thanked 0 Times in 0 Posts

    Smile move_uploaded_file: failed to open stream

    I receive this message when I try to upload an image to my website . Does anyone know what it means and can you give me a basic step by step guide in how to resolve the problem? I am computer illiterate!!

    Warning: move_uploaded_file(adverts/72ef761e130ea1d31be300277b9956dbjpg) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/artscraf/public_html/upload.php on line 29

    Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpy7BgjF' to 'adverts/72ef761e130ea1d31be300277b9956dbjpg' in /home/artscraf/public_html/upload.php on line 29

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Florida, USA
    Thanked 406 Times in 398 Posts
    It means move_uploaded_file() failed to move the file because the filename was wrong or permissions don't allow it to. Try using the full path for the destination ie. /home/artscraf/public_html/adverts/72ef761e130ea1d31be300277b9956dbjpg

    You could also get this error if the file exists and the permissions don't allow writing by the user that php is running as(because move_uploaded_file will overwrite existing files, which is why you should always check to see if the file_exists()).

  • #3
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Saskatoon, Saskatchewan
    Thanked 2,662 Times in 2,631 Posts
    I would like to add a couple of notes as well.
    First off, your permissions may not be set on the folder you are attempting to move it into. You need to ensure that the chmod of the folder you are working in has write permissions for the owner and system. If you are on a windows IIS, this does not apply.
    Secondly, I'd strongly recommend moving into folders that are above your public_html. This allows you just that one extra step to ensure safe files prior to delivering them to the client. If you need an example of this, I believe that firepages actually has one on his site - a masked jpg file that tricks the processor into believing its an image, but is actually a php script.
    Thats my 2 cents
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts