php file upload
Greetings!
I'm trying to use the script below to upload files to my server. I can't get it to work. I'm running PHP 4.3.2 on a Linux server. When I browse for the file and hit the send button it looks like it's working but the file isn't anywhere to be found on the server. I checked the temp directory and the directory it's supposed to copy to. Anyone have any ideas as to why this isn't working?
Thanks!
Rod
--------------------------------------------------------------
<html>
<head>
<title>Listing 9.14 A file upload script</title>
</head>
<?php
$file_dir = "/home/corrdev/htdocs/php24/scrap/uploads";
$file_url = "http://corros.colo.hosteurope.com/dev/php24/scrap/uploads";
foreach( $HTTP_POST_FILES as $file_name => $file_array ) {
print "path: ".$file_array['tmp_name']."<br>\n";
print "name: ".$file_array['name']."<br>\n";
print "type: ".$file_array['type']."<br>\n";
print "size: ".$file_array['size']."<br>\n";
if ( is_uploaded_file( $file_array['tmp_name'] )
&& $file_array['type'] == "image/gif" ) {
move_uploaded_file( $file_array['tmp_name'], "$file_dir/$file_name")
or die ("Couldn't copy");
print "<img src=\"$file_url/$file_name\"><p>\n\n";
}
}
?>
<body>
<form enctype="multipart/form-data" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="51200">
<input type="file" name="fupload"><br>
<input type="submit" value="Send file!">
</form>
</body>
</html>
|