We help IT Professionals succeed at work.

PHP File Upload Indicator

Last Modified: 2013-12-12
I am creating an upload form in PHP. i wish to upload a file and then store the filename in my MySQL database. I have done this before and it is very simple however this time I want a progress indicator for the upload as the files are likely to be around 60Mb.

How can I do this? I know HTML PHP and CSS but very little about any other languages, I have read that this is possible using AJAX and also some PERL scripts that are available online but none seem capable of passing on the rest of the form for insertion into MySQL
Watch Question

This one is on us!
(Get your first solution completely free - no credit card required)


That's not especially helpful, I've already searched the site otherwise I wouldn't be asking. My problem isn't just about uploading the fil but being able to pass the file name back to PHP for manipulation after the file has been stored on the server so i can store the information in a database for other dyanmic areas of the site.

The desired function is as follows...

1- User wants to upload a new mix (the site is for DJ's)
2- User fills out form information; Mix Name, Mix Date and File to be uploaded
3- User hits submit
4- User sees progress bar while file is uploaded
5- After upload is complete the form data is processed by php, the name date and filename+ext are stored in a database
6- That users list of mixes is updated dynamically from the database

So you see i need a solution that enables me to process the form data as normal after the progress indicator is complete. I don't mind how it's done but I need to be able to keep my framework and form processing in PHP
I've had very good luck using Xupload to display an upload progress bar as well as pass along the user-entered data to my processing script for storage in the database. It fits nicely on your existing page and is pretty easy to implement. There's a free version, and a licensed version that contains just a few more features. The free version will do everything you need.  http://www.sibsoft.net/xupload.html


Hi, thanks for your help, I looked at XUpload alread as well as MegaUpload and FileChucker... the problem I'm having is deciphering how to integrate it into my site due to my realtivley novice level skills in PHP.

Without the progress bar my form page will looks 'something' like this...

<form action="<? $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data" name="news" id="news"> <p><label>Mix Name:<br /><input name="mix_name" type="text" size="30" maxlength="50" /></label></p> <p><label>Mix Date:<br /><input name="mix_date" type="text" size="30" maxlength="50" /></label></p> <p><label>Mix MP3 File:<br /><input name="uploadedfile" type="file" id="uploadedfile" size="50" /></label></p> <input type="submit" name="Submit" value="Add Mix" /> </form>

I would then fetch the data from $_POST and process it with something like this...

$target_path = "../uploaded_mix_files/";

            $target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
            if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path))
                $msg .= "<p>The file ".  basename( $_FILES['uploadedfile']['name'])." has been uploaded</p>". "\r\n";

                  $mix_file = basename( $_FILES['uploadedfile']['name']);
                $msg .= "<p>There was an error uploading the file.</p>". "\r\n";
            foreach ($_POST as $k => $v)
                  $v = trim($v) ;
                  $$k = $v ;
            $insert = "INSERT INTO testimonials (mix_name, mix_date, mix_file) VALUES ('$mix_name','$mix_date','$mix_file')";
            $result = mysql_query($insert);
            if (!$result)
                $msg  .= 'Invalid query: ' . mysql_error() . "\r\n";
                $msg .= 'Whole query: ' . $select . "\r\n";
                  $msg .= '<p class="notify">Mix added to database successfully</p>';
                  echo $msg.;

Where would Xupload fit into this workflow?
This one is on us!
(Get your first solution completely free - no credit card required)

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.