Problem with file uploading

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
arjunyerla
Forum Newbie
Posts: 4
Joined: Fri Jul 28, 2006 5:49 am

Problem with file uploading

Post 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.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

Show your code
User avatar
php3ch0
Forum Contributor
Posts: 212
Joined: Sun Nov 13, 2005 7:35 am
Location: Folkestone, Kent, UK

Post by php3ch0 »

have yopu got any code for us to look at?
User avatar
arjunyerla
Forum Newbie
Posts: 4
Joined: Fri Jul 28, 2006 5:49 am

Post 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']);
?>
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post 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
User avatar
arjunyerla
Forum Newbie
Posts: 4
Joined: Fri Jul 28, 2006 5:49 am

Post 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
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

checnge your line to this

Code: Select all

if(move_uploaded_file ($_FILE['file1']['tmp_name'], $filename.$_FILE['file1']['name']))
User avatar
arjunyerla
Forum Newbie
Posts: 4
Joined: Fri Jul 28, 2006 5:49 am

Post by arjunyerla »

Still its giving me the same output that the file cannot be uploaded :(
Post Reply