Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jul 2008
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Problem with uploading images

    Hi,

    i wrote a code to upload a image.In my local it works fine. When i place this code in website through FTP. In that it will not works.
    i am giving the upload path ../upload . When i try to give the chmod permissions in FTP through fileattributes propery to upload folder it will give the message as

    Status: Set permissions of '/admin/upload' to '777'
    Command: SITE CHMOD 777 upload
    Response: 500 'SITE CHMOD 777 upload': command not understood

    code :

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    </head>
    
    <body>
    <form name="Form1" method="post" action="test_add_act.php" enctype="multipart/form-data">
    <input type="hidden" name="chk[]" value="">
    Image<input type="file" name="upload" />
    <br /><input type="submit" name="submit" value="Submit" />
    </form>
    </body>
    </html>
    test_add_act.php

    Code:
    <?
    $filen=$_FILES['upload']['name'];
    $path = '../upload/'.$filen; //generate the destination path
    $imagepath='upload/'.$filen;
    move_uploaded_file($_FILES["upload"]['tmp_name'],$path);
    ?>
    i am getting this error

    Warning: move_uploaded_file(../upload/admin_02.gif) [function.move-uploaded-file]: failed to open stream: Permission denied in C:\Inetpub\vhosts\bodypost.com\httpdocs\admin\test_add_act.php on line 14

    Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\WINDOWS\Temp\php21.tmp' to '../upload/admin_02.gif' in C:\Inetpub\vhosts\bodypost.com\httpdocs\admin\test_add_act.php on line 14


    Anybody Could please tell the solution how can i resolved my problem?

  • #2
    Regular Coder
    Join Date
    Jun 2007
    Location
    N. Ireland
    Posts
    351
    Thanks
    16
    Thanked 4 Times in 4 Posts
    Looks like a permissions error. Check the file permissions on the folder 'upload' and also the parent directory. Should be 777, I think.

    D.
    Daemonkin.
    If this was helpful, please add to my reputation
    Thousand Sons - Freelance Web Developer - ninetyonedegrees.com

  • #3
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    I'm not sure why this is (because people have told me I'm crazy for thinking this), but I've had to specify a full path (from the root) for the destination when using move_uploaded_file(). Meaning, PHP doesn't retain the relative directory when it comes to the destination, so as your destination is "../upload", try changing it to "/admin/upload" (if admin sits on your root dir).

    I still can't make sense of it but that's what I had to do to make it work.


  •  

    Posting Permissions

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