SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Jun 2008
    Posts
    100
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problem with upload 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. #2
    SitePoint Addict skunkbad's Avatar
    Join Date
    Apr 2008
    Location
    Temecula, CA
    Posts
    278
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You might make sure your php.ini has file uploads allowed before doing anything else. If file uploads are enabled, then I think you should call your host, or look at their support docs.

  3. #3
    SitePoint Addict
    Join Date
    May 2006
    Location
    Amsterdam
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    CHMOD is a Unix/Linux command; it's best not to set a Unix/Linux directory to 777.

    It looks like your web server is an IIS Server "C:\WINDOWS". You need to make sure your script has permissions to write to the directory you want to use for uploads. Your web server should have an IIS Admin Tool that will let you configure directory permissions.

    One method that may work for you is to first create the upload directory with the script using mkdir ... as long as PHP has permissions to make a dir in your hosting account it will then "own" the directory it creates; this usually insures that the PHP script then has access to it.

    You haven't posted anything that tests the uploaded file, maybe you have that elsewhere in the script, if not then you may want to take a look at how to test an uploaded file before allowing it to actually live in your website. You can look at this documentation http://nl2.php.net/manual/en/features.file-upload.php and if you want you could explore the PEAR Library http://pear.php.net/


Bookmarks

Posting Permissions

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