-1

I realize that this is a very basic question. Well, to be honest, I am very new. This is the first time that I have worked with php.

The only thing that I am trying to do is to allow internal users to upload to a file to a temporary directory on the server. Here is the php and form code...

HTML
<form enctype="multipart/form-data" action="uploader.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>


PHP
<?php
$target_path = "uploads/";

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    echo "The file ".  basename( $_FILES['uploadedfile']['name']). 
    " has been uploaded";
} else{
    echo "There was an error uploading the file, please try again!";
}
?>

The "uploads" folder is located in the same directory as the html and php. I have verified permissions on that folder that allow the "users" group to read/write.

This is on IIS 8.5 and Windows Server 2012.

When I run this, choose a file and select "upload," it says "No file specified!"

Thanks in advance for any help and I look forward to any information that you can provide as this is my first post on here.

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
Bucfan609
  • 1
  • 1
  • Going to view it on the other thread. I apologize for the duplicate question. I did search before asking...but apparently not enough. – Bucfan609 May 03 '17 at 16:11

1 Answers1

0

Try $target_path = $_SERVER["DOCUMENT_ROOT"]."/uploads";

  • It still says "No File specified." – Bucfan609 May 03 '17 at 15:32
  • The duplicate poste received the following error: Warning: move_uploaded_file(uploads/train.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in D:\Hosting\8234072\html\upload.php on line 6 NOW I GET: Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'D:\Temp\php\php4BA8.tmp' to 'uploads/train.jpg' in D:\Hosting\8234072\html\upload.php on line 6 There was an error uploading the file, please try again! My error was "No File Specified." When commenting, instructions said to provide answers...not ask more questions. I am asking here. – Bucfan609 May 03 '17 at 16:20