View Full Version : PHP Can upload files anywhere except root iis folder

03-07-2007, 09:05 PM

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

03-07-2007, 09:57 PM
Not sure...but sounds like your server does not have file write privileges to that specific folder.