Jump to content

I can upload files anywhere except my remote root folder


Ender22

Recommended Posts

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>

 

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!";
}
?>

 

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

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...  ???

 

any help is greatly appreciated!

 

Thanks!  ;D

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.