Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

Problems with file upload to mysql

Codes here !

Moderators: macek, egami, gesf

Problems with file upload to mysql

Postby moorstream » Mon Jul 14, 2003 9:08 pm

This is the form code:
<code><FORM METHOD="post" ACTION="dbAddFile.php" ENCTYPE="multipart/form-data">
<INPUT TYPE="hidden" NAME="MAX_FILE_SIZE" VALUE="1000000">
<INPUT TYPE="hidden" NAME="action" VALUE="upload">
<TABLE BORDER="1"><TR><TD>Description: </TD>
<TD><TEXTAREA NAME="txtDescription" ROWS="10" COLS="50"></TEXTAREA></TD></TR>
<TR> <TD>File: </TD>
<TD><INPUT TYPE="file" NAME="binFile"></TD></TR>
<TR><TD COLSPAN="2"><INPUT TYPE="submit" VALUE="Upload"></TD></TR></TABLE></FORM></code>

... and my php file upload script:
<code>if (isset($binFile) && $binFile != "none") {
$data = addslashes(fread(fopen($binFile, "r"), filesize($binFile)));
$strDescription = addslashes(nl2br($txtDescription));
$sql = "INSERT INTO Filer (filnamn, fil, storlek, typ, kommentar) VALUES ('$binFile_name', '$data', '$binFile_size', '$binFile_type', '$txtDescription')";
if (!$result = mysql_query($sql, $db)){
echo mysql_errno($db);
echo mysql_error($db);
exit();}}</code>

This works ok when I upload files which size is less than 32767. I can download theese files and use them. Bigger files only store 32767 bytes of data and are corrupted when I download them. The field is mediumblob, but I get the same result with blob and longblob.

post_max_size is 8M andupload_max_filesize is 2M

/Moorstream
moorstream
New php-forum User
New php-forum User
 
Posts: 5
Joined: Thu Jul 10, 2003 2:39 am

Postby swirlee » Tue Jul 15, 2003 6:21 am

The exact same question was answered last week. Please use the board's Search function before asking a question.

Also, make sure your field is big enough. If you're using a BLOB, try using a MEDIUMBLOB or LONGBLOB instead.
User avatar
swirlee
Moderator
Moderator
 
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back

Postby moorstream » Tue Jul 15, 2003 7:11 am

As I wrote, the field is mediumblob and I've tried blob and longblob. Doesn't matter. I get the same error. I just want to know why I get this error of not completely uploaded files

/Moorstream
moorstream
New php-forum User
New php-forum User
 
Posts: 5
Joined: Thu Jul 10, 2003 2:39 am

Postby swirlee » Tue Jul 15, 2003 7:20 am

moorstream wrote:As I wrote, the field is mediumblob and I've tried blob and longblob.


Missed that part. Read the thread I linked to above and if it still doesn't work, let me know.
User avatar
swirlee
Moderator
Moderator
 
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back


Return to mySQL & php coding

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.