PDA

View Full Version : Php Upload Script



b.rich
June 23rd, 2004, 06:17 PM
Hi,

I have a simple upload script that seems to work, but it uploads the file as 0mb. Below is the script that the form post too. Anyone see anything wrong with it? I can't figure it out, please help.


<?php
$file_dir = "/u/htdocs/path/";

foreach($_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'])) {
move_uploaded_file($file_array['tmp_name'],
"$file_dir/$file_array[name]") or die ("Error, it seems there was a problem");
print "file was moved!<br><br>";
}
}
?>

Thanks.

b.rich
June 23rd, 2004, 07:16 PM
got it to work!@! yeah!! not that anyone would care but here is the code...

I had it as an array which is where i messed up.


<?php
$uploaddir = '/u/htdocs/path/'; //this is my main image directory
$uploadfile = $uploaddir . $_FILES['userfile']['name'];

print "path: ".$_FILES['userfile']['tmp_name']."<br>\n";
print "name: ".$_FILES['userfile']['name']."<br>\n";
print "type: ".$_FILES['userfile']['type']."<br>\n";
print "size: ".$_FILES['userfile']['size']."<br>\n";
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile));

//oldcode move_uploaded_file($_FILES['userfile']['tmp_name'],
//oldcode "$uploadfile") or die ("Error, it seems there was a problem");

print "file was moved!<br><br>";

?>