Multiple File Upload Script

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Brad7928
Forum Commoner
Posts: 39
Joined: Thu Jan 29, 2009 4:54 pm

Multiple File Upload Script

Post 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
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: Multiple File Upload Script

Post by jaoudestudios »

You could use jquery & php.

Take a look at this http://t.wits.sg/2008/06/25/howto-php-a ... gress-bar/
Brad7928
Forum Commoner
Posts: 39
Joined: Thu Jan 29, 2009 4:54 pm

Re: Multiple File Upload Script

Post by Brad7928 »

i am running an xampp based server on windows XP. how can i install that package?
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: Multiple File Upload Script

Post 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.
maneetpuri
Forum Commoner
Posts: 60
Joined: Tue Oct 07, 2008 6:32 am

Re: Multiple File Upload Script

Post by maneetpuri »

Hi,

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

It has the features you need.

Cheers,
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: Multiple File Upload Script

Post 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!
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Multiple File Upload Script

Post by VladSun »

There are 10 types of people in this world, those who understand binary and those who don't
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: Multiple File Upload Script

Post 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.
Brad7928
Forum Commoner
Posts: 39
Joined: Thu Jan 29, 2009 4:54 pm

Re: Multiple File Upload Script

Post 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?
Brad7928
Forum Commoner
Posts: 39
Joined: Thu Jan 29, 2009 4:54 pm

Re: Multiple File Upload Script

Post 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>
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Multiple File Upload Script

Post 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/
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Multiple File Upload Script

Post by Eran »

off topic: what happened to pecl4win ? it's been down for several months now. I need my compiled PECL packages!
Brad7928
Forum Commoner
Posts: 39
Joined: Thu Jan 29, 2009 4:54 pm

Re: Multiple File Upload Script

Post 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
frisket
Forum Newbie
Posts: 1
Joined: Thu Mar 19, 2009 4:23 am

Re: Multiple File Upload Script

Post 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"];
Post Reply