Jump to content


Photo

file upload


  • Please log in to reply
6 replies to this topic

#1 mistakes!

mistakes!
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 11 May 2006 - 01:41 AM

hello i am trying to run this file upload form and it outputs the following error
There 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?
$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"); 
pls help me

#2 litebearer

litebearer
  • Members
  • PipPipPip
  • Advanced Member
  • 2,357 posts
  • Locationwhite lake michigan

Posted 11 May 2006 - 02:06 AM

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...

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..");
      }

and remove all the comments, plus do some careful indenting like so...

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..");
    }

It would appear that you are missin gyour final brace, and that may be a part of the problem.

Lite...

all the brothers were valiant!

[br][br]The truely intelligent people are not those who create the dots; rather they are they ones with the ability to connect the dots into a coherent picture

#3 mistakes!

mistakes!
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 11 May 2006 - 02:18 AM


hello i have tried that i am stil getting the same errors

#4 litebearer

litebearer
  • Members
  • PipPipPip
  • Advanced Member
  • 2,357 posts
  • Locationwhite lake michigan

Posted 11 May 2006 - 02:28 AM

Hmmm, ok. Do you mind showing us your form?

all the brothers were valiant!

[br][br]The truely intelligent people are not those who create the dots; rather they are they ones with the ability to connect the dots into a coherent picture

#5 mistakes!

mistakes!
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 11 May 2006 - 02:32 AM

sorry do u mean the whole code?


#6 sumityadav

sumityadav
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 11 May 2006 - 04:56 AM

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) View Post[/div][div class=\'quotemain\'][!--quotec--]
sorry do u mean the whole code?
[/quote]


#7 colincannon

colincannon
  • Members
  • Pip
  • Newbie
  • 3 posts

Posted 11 May 2006 - 05:34 AM

I had a similar problem with the move_uploaded_file

temporarily, 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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users