Page 1 of 1

Problem with file uploading

Posted: Fri Jul 28, 2006 6:18 am
by arjunyerla
Hi Guyz

can any one plz help me, i have a problem with my upload php script which i could not figure out.

my problem is when ever im trying to upload any file it is not getting upladed in to the temporary directory which i specified in the php.ini file but when im chechking it using the function is_uploaded_file method it i sshowing that the file has been uploaded.

Posted: Fri Jul 28, 2006 6:20 am
by JayBird
Show your code

Posted: Fri Jul 28, 2006 6:21 am
by php3ch0
have yopu got any code for us to look at?

Posted: Fri Jul 28, 2006 6:26 am
by arjunyerla
here is my code...

Code: Select all

<?php
$filename = $_FILE['file1']['name'];
if(move_uploaded_file ($_FILE['file1']['tmp_name'], "$filename"))
{
	print "File has been Uploded succesfully!!!";
}
else
{
	echo "Failed to upload file Contact Site admin to fix the problem";
}
print is_uploaded_file($_FILES['file1']['tmp_name']);
?>

Posted: Fri Jul 28, 2006 6:40 am
by JayBird
Add this...

Code: Select all

echo '<pre>';
print_r($_FILES);
print "</pre>";
and post the output

also, your not telling it what directory to move the file to

Posted: Fri Jul 28, 2006 7:59 am
by arjunyerla
CODE:

Code: Select all

<?php
$filename = "c:/php/temp/";
echo '<pre>';
print_r($_FILES);
print "</pre>"; 
if(move_uploaded_file ($_FILE['file1']['tmp_name'], "$filename"))
{
	print "File has been Uploded succesfully!!!";
}
else
{
	echo "Failed to upload file Contact Site admin to fix the problem";
}
print $_FILES['file1']['tmp_name'];
print is_uploaded_file($_FILES['file1']['tmp_name']);
?>

OUTPUT:


Array
(
[file1] => Array
(
[name] => Substraction.java
[type] => application/octet-stream
[tmp_name] => C:\WINDOWS\php8E.tmp
[error] => 0
[size] => 192
)

)

Failed to upload file Contact Site admin to fix the problemC:\WINDOWS\php8E.tmp

Posted: Fri Jul 28, 2006 8:08 am
by JayBird
checnge your line to this

Code: Select all

if(move_uploaded_file ($_FILE['file1']['tmp_name'], $filename.$_FILE['file1']['name']))

Posted: Fri Jul 28, 2006 8:49 am
by arjunyerla
Still its giving me the same output that the file cannot be uploaded :(