mistakes! Posted May 11, 2006 Share Posted May 11, 2006 hello i am trying to run this file upload form and it outputs the following errorThere was a error in uploading please try again..Sorry unable to connect to the database..the paper directory is a folder inside a folder where i will like to store all uploaded files, pls any ideas why it is not working?[code]$dir="papers/";$area=$_POST['area'];$event=$_POST['event']; //take values from previous file.$filename=basename($_FILES['paper']['name']);$dir=$dir.basename($_FILES['paper']['name']);$ext= explode('.',$filename);$ext = $ext[count($ext)-1];if($ext==='doc' || $ext==='pdf') //check if the file is doc. { if(move_uploaded_file($_FILES['paper']['tmp_name'],$dir)) //move the file to papers directory. { print("The file as been uploaded"); } else { print("There was a error in uploading please try again.."); } $link = mysql_connect("localhost" , "outreach") or die("Could not connect to the database"); [/code]pls help me Quote Link to comment Share on other sites More sharing options...
litebearer Posted May 11, 2006 Share Posted May 11, 2006 first one must remember the title Guru is like an honorary degree, it doesn't mean I know anything. That said, I am not sure this is the root of your problem; however, if we take this portion of your script...[code]if($ext==='doc' || $ext==='pdf') //check if the file is doc. { if(move_uploaded_file($_FILES['paper']['tmp_name'],$dir)) //move the file to papers directory. { print("The file as been uploaded"); } else { print("There was a error in uploading please try again.."); }[/code]and remove all the comments, plus do some careful indenting like so...[code]if($ext==='doc' || $ext==='pdf'){ if(move_uploaded_file($_FILES['paper']['tmp_name'],$dir)) { print("The file as been uploaded"); }else{ print("There was a error in uploading please try again.."); }[/code]It would appear that you are missin gyour final brace, and that may be a part of the problem.Lite... Quote Link to comment Share on other sites More sharing options...
mistakes! Posted May 11, 2006 Author Share Posted May 11, 2006 hello i have tried that i am stil getting the same errors Quote Link to comment Share on other sites More sharing options...
litebearer Posted May 11, 2006 Share Posted May 11, 2006 Hmmm, ok. Do you mind showing us your form? Quote Link to comment Share on other sites More sharing options...
mistakes! Posted May 11, 2006 Author Share Posted May 11, 2006 sorry do u mean the whole code? Quote Link to comment Share on other sites More sharing options...
sumityadav Posted May 11, 2006 Share Posted May 11, 2006 Boss although you need help and we ppl try to workout on your problems and you are showing such attitude that the snippet will help... Too bad..Show some more code and explain some more on the problem...[!--quoteo(post=373158:date=May 11 2006, 08:02 AM:name=mistakes!)--][div class=\'quotetop\']QUOTE(mistakes! @ May 11 2006, 08:02 AM) [snapback]373158[/snapback][/div][div class=\'quotemain\'][!--quotec--]sorry do u mean the whole code?[/quote] Quote Link to comment Share on other sites More sharing options...
colincannon Posted May 11, 2006 Share Posted May 11, 2006 I had a similar problem with the move_uploaded_filetemporarily, set the permissions of the dir that you are moving the file to, to 777 that was a problem I had, the dir did not have permissions to be written to Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.