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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Mar 2007
    Thanked 0 Times in 0 Posts

    PHP Can upload files anywhere except root iis folder


    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 />

    which is directory to uploader.php page with code:

    // $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 ";
        echo "There was an error uploading the file, please try again!";

    by the way my remote directory folder is:

    when my target path is:

    $target_path = "/uploads/"; 
    $target_path = "C:/Inetpub/wwwroot/GetPHPToWork/uploads/";
    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/"
    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

    Im not sure why I cant upload to the folder I want... Huh

    any help is greatly appreciated!

    Thanks! Grin

  • #2
    ess is offline
    Regular Coder
    Join Date
    Oct 2006
    United Kingdom
    Thanked 30 Times in 29 Posts
    Not sure...but sounds like your server does not have file write privileges to that specific folder.


    Posting Permissions

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