cant get file upload to work on localhost

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

cant get file upload to work on localhost

Post by Luke »

i swear... configuration problems are the most frustrating thing in the world. I could punch a kitten right now. anyway... I cannot get file uploads to work on my local machine. I have my upload_tmp_dir set to "C:\tmp\uploads". I upload a file, and it says in the $_FILES array that there is now a file available at "C:\tmp\uploads\php86.tmp" but then I go to the directory and it isn't there. so I changed the upload_tmp_dir to C:\PHP\tmp and still I get nothing, and yet every time I do an upload, it says there is now a file available in $_FILES['file']['tmp_name']. also move_uploaded_file doesn't work (of course).
ianhull
Forum Contributor
Posts: 310
Joined: Tue Jun 14, 2005 10:04 am
Location: Hull England UK

Post by ianhull »

Is the directory writeable?

chmod?
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

I'm on windows
ianhull
Forum Contributor
Posts: 310
Joined: Tue Jun 14, 2005 10:04 am
Location: Hull England UK

Post by ianhull »

server 2003?

I found that when installing php5 on s2k3 i had some teething problems, I then tried the installer which totally failed.

I then follwed some new instructions, did not realise that I had two php.ini files one in C:/php and 1 oin C:/WINDOWS

have you checked you are using the correct .ini too?

just a thought.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

yep it's the right one :(
ianhull
Forum Contributor
Posts: 310
Joined: Tue Jun 14, 2005 10:04 am
Location: Hull England UK

Post by ianhull »

Are you uploading a picture? .jpg, or .gif?

If you are maybe you could try outputting it using image straight from the

Code: Select all

$_FILES['file']['tmp_name'];
Seems strange does this one :cry:
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

here is the output of a var_dump($_FILES);

Code: Select all

array(1) {
  ["data"]=>
  array(5) {
    ["name"]=>
    array(1) {
      ["Import"]=>
      array(1) {
        ["import"]=>
        string(33) "2007_Tax_Worksheet_JL_10-4-07.doc"
      }
    }
    ["type"]=>
    array(1) {
      ["Import"]=>
      array(1) {
        ["import"]=>
        string(18) "application/msword"
      }
    }
    ["tmp_name"]=>
    array(1) {
      ["Import"]=>
      array(1) {
        ["import"]=>
        string(27) "C:\uploaded_files\php1D.tmp"
      }
    }
    ["error"]=>
    array(1) {
      ["Import"]=>
      array(1) {
        ["import"]=>
        int(0)
      }
    }
    ["size"]=>
    array(1) {
      ["Import"]=>
      array(1) {
        ["import"]=>
        int(53760)
      }
    }
  }
}
see how it says that it's available now at "C:\uploaded_files\php1D.tmp" -- well it isn't there! :(
ianhull
Forum Contributor
Posts: 310
Joined: Tue Jun 14, 2005 10:04 am
Location: Hull England UK

Post by ianhull »

Yes, that is strange.

Have you restared the server since configuration?

Not sure what going on with this one.

have you tried using error checking?

Code: Select all

E_ALL
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

I have tried the same script on my host and it worked. I tried it locally on another machine here and I got the same results as I did on my local machine. The files just WONT stay there. GRR where's a kitten when you need one?? Image
ianhull
Forum Contributor
Posts: 310
Joined: Tue Jun 14, 2005 10:04 am
Location: Hull England UK

Post by ianhull »

Are you using apache or IIS?
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

apache
ianhull
Forum Contributor
Posts: 310
Joined: Tue Jun 14, 2005 10:04 am
Location: Hull England UK

Post by ianhull »

Can you post your .ini?
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

Ole suggests checking for "allow_file_uploads" in PHP.ini... appendix i.

My thought is to try using Uniform Server and see if the problem persists.

For the kitten comment:
Image
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

Kieran Huggins wrote:Ole suggests checking for "allow_file_uploads" in PHP.ini... appendix i.
Kieran is lazy. This is what I was referring to. You should check these configuration settings with ini_get() make sure they are what you're expecting. Otherwise I don't know what's going on.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Could you please try

Code: Select all

<html>
	<body>
		<form enctype="multipart/form-data" action="?" method="POST">
			<div>
				Send this file: <input name="data[Import][import]" type="file" />
				<input type="submit" value="Send File" />
			</div>
		</form>
<?php
if ( isset($_FILES['data']['tmp_name']['Import']['import']) && 0==$_FILES['data']['error']['Import']['import'] ) {
	check(dirname($_FILES['data']['tmp_name']['Import']['import']));
	check($_FILES['data']['tmp_name']['Import']['import']);
}
else {
	echo 'upload failure.';
	echo '<pre>', var_dump($_FILES, true), "</pre>\n";
}

function check($path) {
	if ( !file_exists($path) ) {
		echo $path, " does not exist<br />\n";
	}
	else {
		echo
			is_dir($path) ? 'd':'-',
			is_readable($path) ? 'r':'-',
			is_writeable($path) ? 'w':'-',
			is_executable($path) ? 'x':'-',
			' ', $path;
		if ( is_file($path) ) {
			$fd = fopen($path, 'rb');
			if ( !$fd ) {
				echo '[ fopen failed ]';
			}
			else {
				fseek($fd, 0, SEEK_END);
				echo '[ ftell ', ftell($fd), ']';
				fclose($fd);
			}
		}
		echo "<br />\n";
	}
}
?>
	</body>
</html>
Post Reply