Jump to content

How to make a simple progress bar


garethhall

Recommended Posts

Hey guys,

 

Can anyone point me in the right direction please.

 

I have this code below that clearly load a file into a blob, I would like to add a progress bar to this code. Can anyone here help me out or point me to the right place?

 

Thanks in advance.

 

<?php
if($submitFrm == "true"){
echo "working";
$fileName = $_FILES['userfile']['name'];
$tmpName  = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];
$fp = fopen($tmpName, 'r');
$content = fread($fp, filesize($tmpName));
$content = addslashes($content);
fclose($fp);
$newCvName = $fullName." 1";
if(!get_magic_quotes_gpc()){
    	$newCvName = addslashes($newCvName);
};

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
mysql_select_db($dbname);

$query = "INSERT INTO resumes (fileName, fileSize, fileType, content, applicantName, dateUploaded ) ".
"VALUES ('$newCvName', '$fileSize', '$fileType', '$content', '$fullName', now() )";

mysql_query($query) or die('Error, query failed');
mysql_close($conn);

}else{
echo "error";
};
?>

Link to comment
Share on other sites

I assume that this is an upload script. For a progress bar (which tracks the progress e.g. 10%, 20% etc..) you will need to use JavaScript; however, you cannot use PHP and JavaScript alone to track the progress, you will need to use some other language such as perl or python or java because JavaScript cannot access the file system to see how much of the file is uploaded and with PHP the file has to be completely uploaded in order for it to determine the filesize. Alternatively you could use flash.

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.