Jump to content

file upload


mistakes!

Recommended Posts

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?
[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
Link to comment
Share on other sites

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...
Link to comment
Share on other sites

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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.