View Full Version : execuation time for uploading files?

03-01-2009, 11:28 AM
hello guys .

i wonder what is the best way that you guys would do for a script that does upload the file and a script that can view uploaded file and click the link and download it .

i am trying to upload the file into database as BLOB type and i am able to do it only for small size files. i can not upload for like 2-5MB (typical an mp3 file )

my code is like this

if(isset($_POST['upload']) && $_FILES['userfile']['size'] > 0)
$fileName = (isset($_FILES['userfile']['name'])) ? $_FILES['userfile']['name'] : '';
$tmpName = (isset($_FILES['userfile']['tmp_name'])) ? $_FILES['userfile']['tmp_name'] : '';
$fileSize = (isset($_FILES['userfile']['size'])) ? $_FILES['userfile']['size'] : '';
$fileType = (isset($_FILES['userfile']['type'])) ? $_FILES['userfile']['type'] : '';
$fileError = (isset($_FILES['userfile']['error'])) ? $_FILES['userfile']['error'] : '';

if ($fileError > 0)
echo "errorerrorerror";

$fp = fopen($tmpName, 'r');
$content = fread($fp, filesize($tmpName));
$content = addslashes($content);

$connection = new DBManager;

$fileName = addslashes($fileName);

$query = "INSERT INTO upload (name, size, type, content ) ".
"VALUES ('$fileName', '$fileSize', '$fileType', '$content')";

if ($connection->query($query)){
echo "<br/>File $fileName uploaded <br/>";
} else {
echo "$fileName is NOT uploaded";


<form method="post" enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF'] ?>">
<table width="350" border="0" cellpadding="1" cellspacing="1">
<td width="246">
<input type="hidden" name="MAX_FILE_SIZE" value="40960">
<input name="userfile" type="file" id="userfile">
<input name="upload" type="submit" id="upload" value="Upload">

it wont let me upload file like i guess more that 2MB ( or even more than 1MB )

is there any config in php.ini ( well there is but the max file upload by default is 16M if I am not mistaken ) ....

or Can't I not upload a song file into Database ?

how do you guys normally do for kinda like file manager where one side can upload and one side can download it ?

thanks in advance

03-01-2009, 12:34 PM
Are you getting any error while uploading? Does your network have enough speed to transfer the file before the max_execution time (set in your ini file)?

03-02-2009, 05:04 PM
i dont get any error and the script just does not execute properly i think . then it gets back to orginial as if nothing happened.

no i am trying this upload / download in localhost . there should n't be netwrk issue .

btw .on this one i upload data into database.

i actually wanted to upload data into a directory in web server then we are able to sort of manipulate the data such as sorting them by the day those data are uploaded.... or by how big is the size of the data.

if i want to do that, i would have to use database right ? is there any way that i dont store the data into database but on the "download page" people could find the data (in ordered fashion such as by time uploaded / size of the data )and then they can download it based on the link that they have.

thanks :)