Jump to content

Problems uploading files


charlie_d

Recommended Posts

Hi, I am new to PHP and am having major problems with a basic upload script as follows:

 

Using php 5.2.5 and IIS on my local machine.

Am trying to run a very basic upload script

 

print_r($_FILES); gives me all the correct details of the uploaded file and [error] => 0

but when I check the tmp upload folder as specified in php.ini and as returned by print_r($_FILES); , there is no .tmp file.

 

Also move_uploaded_file always returns false.

 

What am I doing wrong

Link to comment
https://forums.phpfreaks.com/topic/94166-problems-uploading-files/
Share on other sites

Thanks discomatt but;

 

Images folder exists and I have also tried using different folders created sepecially to test this, and I have used both relative and absolute paths and with slashes going both ways.

 

Still getting nowhere

 

Due to loss of posts - here is problem again in full:

 

I am using php 5.2.5 and IIS 5.1 on MS Windows Pro with SP2 installed

 

I am attempting a simple file upoad with first page:

 

 

<form enctype="multipart/form-data" action="test_uploadck.php" method="POST">
    <!-- MAX_FILE_SIZE must precede the file input field -->
    <input type="hidden" name="MAX_FILE_SIZE" value="75000" />
    <!-- Name of input element determines name in $_FILES array -->
    Send this file: <input name="userfile" type="file" />
    <input type="submit" value="Send File" />
</form>

 

and test_uploadck.php:

 

<?php
ini_set ("display_errors", "1");
error_reporting(E_ALL);
print "<pre>";

$target_path = 'Images/';
$target_path = $target_path . basename( $_FILES['userfile']['name']); 

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

echo 'Here is some more debugging info:';
print_r($_FILES);

print "</pre>";
?> 

 

I get the following errors:

 

Warning:  move_uploaded_file(Images/AL19307A.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in C:\Inetpub\wwwroot\estateagent1\test_uploadck.php on line 18

Warning:  move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\PHP\tmp\php43.tmp' to 'Images/AL19307A.jpg' in C:\Inetpub\wwwroot\estateagent1\test_uploadck.php on line 18

 

I have checked the standard pitfalls as follows:

 

a) the file being uploaded was not too big (only 22K) and did not exceed either MAX_FILE_SIZE (750000) in the script or post_max_size and upload_max_filesize (both 8M) in php.ini.

b) the folder I was moving the uploaded file to exists and has all permissions enabled in IIS

c) There were no normal input fields in the upload form

 

Where am I going wrong?

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.