Page 1 of 1

Multiple File Upload Script

Posted: Sun Feb 01, 2009 11:48 pm
by Brad7928
I'm wanting to have a upload page on my website that allows users to only upload certain files. I have found an example here http://rauru.com/a-simple-file-upload-script-using-php/ but it doesn't have a progress bar. Any ideas on how to intergrate a progress bar? Or does anyone know of a script that would suit my needs?

Thanks in advance,

Brad

Re: Multiple File Upload Script

Posted: Mon Feb 02, 2009 3:13 am
by jaoudestudios
You could use jquery & php.

Take a look at this http://t.wits.sg/2008/06/25/howto-php-a ... gress-bar/

Re: Multiple File Upload Script

Posted: Mon Feb 02, 2009 4:10 am
by Brad7928
i am running an xampp based server on windows XP. how can i install that package?

Re: Multiple File Upload Script

Posted: Mon Feb 02, 2009 4:53 am
by jaoudestudios
Not sure, you will have to google the package with windows.

I definitely recommend going to linux for your development environment as your production server will probably be linux - this way you wont have any surprises when you make your website live.

Re: Multiple File Upload Script

Posted: Mon Feb 02, 2009 5:30 am
by maneetpuri
Hi,

Check this: - http://www.koolphp.net/?mod=products&ac ... xwodDUCVaA

It has the features you need.

Cheers,

Re: Multiple File Upload Script

Posted: Mon Feb 02, 2009 10:56 am
by jaoudestudios
maneetpuri wrote:Hi,

Check this: - http://www.koolphp.net/?mod=products&ac ... xwodDUCVaA

It has the features you need.

Cheers,
Its not opensource!

Re: Multiple File Upload Script

Posted: Mon Feb 02, 2009 10:59 am
by VladSun

Re: Multiple File Upload Script

Posted: Mon Feb 02, 2009 11:09 am
by jaoudestudios
extJs is good, but a massive library. From what I remember it is about 0.5MB. And just to use that for an upload system is quite heavy going. I have not looked at it in a while, so I could be wrong as things might have changed.

Re: Multiple File Upload Script

Posted: Mon Feb 02, 2009 5:16 pm
by Brad7928
I agree, it is not opensource! Although it does look rather good.

I have had a look at the ExtJS solution, but i can't see how to implement the upload panel into a page. Any help?

Re: Multiple File Upload Script

Posted: Mon Feb 02, 2009 7:08 pm
by Brad7928
Found this other script on the web (why re-invent the wheel?)

Code: Select all

 
 
<?php
 
if ((($_FILES["file"]["type"] == "image/gif")
 
|| ($_FILES["file"]["type"] == "image/jpeg")
 
|| ($_FILES["file"]["type"] == "image/pjpeg"))
 
&& ($_FILES["file"]["size"] < 20000))
 
  {
 
  if ($_FILES["file"]["error"] > 0)
 
    {
 
    echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
 
    }
 
  else
 
    {
 
    echo "Upload: " . $_FILES["file"]["name"] . "<br />";
 
    echo "Type: " . $_FILES["file"]["type"] . "<br />";
 
    echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
 
    echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";    if (file_exists("uploads/" . $_FILES["file"]["name"]))
 
      {
 
      echo $_FILES["file"]["name"] . " already exists. ";
 
      }
 
    else
 
      {
 
      move_uploaded_file($_FILES["file"]["tmp_name"],
 
      "upload/" . $_FILES["file"]["name"]);
 
      echo "Stored in: " . "uploads/" . $_FILES["file"]["name"];
 
      }
 
    }
 
  }
 
else
 
  {
 
  echo "Invalid file";
 
  }
 
?>
 
 
 
 
But no matter what I upload it always errors with the “invalid file” message.

This is the form i'm using to call the upload.php file

Code: Select all

<form enctype="multipart/form-data" action="uploader.php" method="POST">
Choose a file to upload: <input name="file" type="file" /><br />
<input type="submit" value="Upload File" />
</form>

Re: Multiple File Upload Script

Posted: Mon Feb 02, 2009 7:56 pm
by VladSun
jaoudestudios wrote:extJs is good, but a massive library. From what I remember it is about 0.5MB. And just to use that for an upload system is quite heavy going. I have not looked at it in a while, so I could be wrong as things might have changed.
You can build a set of modules of your choice:
http://extjs.com/products/extjs/build/

Re: Multiple File Upload Script

Posted: Mon Feb 02, 2009 8:02 pm
by Eran
off topic: what happened to pecl4win ? it's been down for several months now. I need my compiled PECL packages!

Re: Multiple File Upload Script

Posted: Mon Feb 02, 2009 8:30 pm
by Brad7928
I don't really want to go the ExtJS way...

I have had another look on the net and found that if i want a progress bar i need to include perl scripts in the php.

If someone could tell me or atleast hinto to where i'm going wrong with the above code it would be helpful.

Cheers,

Brad

Re: Multiple File Upload Script

Posted: Thu Mar 19, 2009 4:29 am
by frisket
Brad7928 wrote:Found this other script on the web (why re-invent the wheel? [...]But no matter what I upload it always errors with the “invalid file” message.
I just tried this and it seems to works OK (I edited out all the double-newlines) but I changed the error line to echo the type and size.

Code: Select all

echo "Invalid file type/size: " . $_FILES["file"]["type"] . ":" . $_FILES["file"]["size"];