I can upload a file (with php) to anywhere except my remote root folder!

Discussion in 'PHP' started by Ender22, Mar 5, 2007.

  1. #1
    Hello!

    Thanks for taking the time to read my post.

    Im working on a project with PHP that allows users to upload pictures to my server and then reference them.
    After going through some uploading tutorials I have the uploading part working Except! I cant upload folders to my remote root folder. I need to allow the users to upload somewhere inside the root folder so they can reference the pictures in code after.

    Just to clarify the uploading works perfectly if I put the uploads folder anywhere on my computer except the sites remote root folder (or anywhere inside the root folder)
    I also beleive I am giving the folder all of the proper permissions because I am giving the uploads folder in my root directory (the one that doesnt work) the same permissions as the one outside the root (the one that works)

    Here is a specific example with my code of the problem.

    My html file containing the form:

    
    <form enctype="multipart/form-data" action="uploader.php" method="POST">
      <div align="center">
        <input type="hidden" name="MAX_FILE_SIZE" value="100000" />
        Please choose a file to upload: 
        <input name="uploadedfile" type="file" />
        <input name="submit" type="submit" value="Upload File" />
        <br />
      </div>
    </form>
    
    Code (markup):
    which is directory to uploader.php page with code:

    
    <?php
    
    // $target_path = "/uploads/"; // this path doesnt work
    // $target_path = "C:/Inetpub/wwwroot/GetPHPToWork/uploads/" // this path also doesnt work
    $target_path = "C:/Inetpub/uploads/"; // this path or any other path with permissions on my computer works!
    
    $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 
    
    if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) 
    {
        echo " The file has been uploaded ";
    }
     else
     {
        echo "There was an error uploading the file, please try again!";
     }
    ?>
    
    Code (markup):
    by the way my remote directory folder is:
    "C:\Inetpub\wwwroot\GetPHPToWork\"

    when my target path is:
    
    $target_path = "/uploads/"; 
    $target_path = "C:/Inetpub/wwwroot/GetPHPToWork/uploads/" 
    ]
    Code (markup):
    I get my php echo "There was an error uploading the file, please try again!";

    but if the path is
    
    $target_path = "C:/Inetpub/uploads/" 
    
    Code (markup):
    it works perfectly.

    here is my upload settings in php.ini incase you want to see them:

    
    ;;;;;;;;;;;;;;;;
    ; File Uploads ;
    ;;;;;;;;;;;;;;;;
    
    ; Whether to allow HTTP file uploads.
    file_uploads = On
    
    ; Temporary directory for HTTP uploaded files (will use system default if not
    ; specified).
    upload_tmp_dir = C:/PHP/uploadtemp/ 
    
    ; Maximum allowed size for uploaded files.
    upload_max_filesize = 20M
    
    Code (markup):
    Im not sure why I cant upload to the folder I want... ???

    any help is greatly appreciated!

    Thanks! ;D
     
    Ender22, Mar 5, 2007 IP
  2. picouli

    picouli Peon

    Messages:
    760
    Likes Received:
    89
    Best Answers:
    0
    Trophy Points:
    0
    #2
    picouli, Mar 6, 2007 IP
  3. Ender22

    Ender22 Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Sorry I dont think so...

    From my php.ini file:

    
    ;
    ; Safe Mode
    ;
    safe_mode = Off
    
    Code (markup):
    any other ideas?
     
    Ender22, Mar 6, 2007 IP