By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,846 Members | 1,709 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,846 IT Pros & Developers. It's quick & easy.

file uploading problem

ganesanji
P: 16
hi all,

I have written a php coding for uploading a file to a specific folder or location in
server which is a Linux server. I think the coding for file uploaing is correct.
But it does not work properly. That means the file is not uploaded to the specified location. It always executes the "else" condition in my coding.
I think the problem is lieing in the specifed path which is the target path for file uploading. I could not find out the solution for that. Please any body help me...

I attached the coding below.......
[php]
<form action="<? echo $PHP_SELF; ?>" method="post" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="20000" />
Names file: <input type="file" name="myfile">
<input type="submit" name="upload" value="UploadFile" class="butt">
</form></center>

if($_POST)
{
$path = '/var/www/uploads/';
$path .= $_FILES['myfile']['name'];
$_SESSION['path']=$path;
if(move_uploaded_file($_FILES['myfile']['tmp_name'],$path))
{
echo "Successfully uploaded";
}
else
{
echo "Uploading Error";
}
}
?>
[/php]
In this coding it always executes "Uploading Error".....

Any body help me....
I will greatfull for you.........thanks....
Oct 11 '07 #1
Share this Question
Share on Google+
3 Replies


MarkoKlacar
Expert 100+
P: 296
Hi,

have you looked at php.net? Here you will find examples of how to cope with the $_FILE.

Start here, I know it's not that difficult.

Cheers
Oct 17 '07 #2

Markus
Expert 5K+
P: 6,050
Hmmm...

Is that supposed to be a comma? - in the if statement..?
Expand|Select|Wrap|Line Numbers
  1. if(move_uploaded_file($_FILES['myfile']['tmp_name'],$path))
  2.                                                  //^ comma?
  3.  
I'm thinking it should be a fullstop :)
Oct 18 '07 #3

ronverdonk
Expert 2.5K+
P: 4,258
ganesanji: Next time enclose any code within the proper code tags.

See the Posting Guidelines on how to do that.

moderator
Oct 18 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.