Query keeps failing...
Posted: Wed Mar 16, 2005 2:31 am
Anybody know why this keeps failing. Don't ask why I need to do it but I need to upload files directly to MySQL. I'm using a MEDIUMBLOB column type to store the data. Data could be up to 10MB.
I'm only practising at the moment so this couldn't be any simpler.... the table consists of just two columns. FileID (SMALLINT(4) AUTO_INCREMENT) and the one for the data, fileData (MEDIUMBLOB).
It apperas that small files (i.e. 10KB upload fine, but anything over about 50 or 60KB fails). I can't give an Error Message because it doesn't return one
I just get my die() statement.
I'm not being daft and the file IS there...
I'm probably not doing it right... I've followed tutorials which use the same method (except they do the obviousy adding filesize, and filename etc to other columns..)
I'm only practising at the moment so this couldn't be any simpler.... the table consists of just two columns. FileID (SMALLINT(4) AUTO_INCREMENT) and the one for the data, fileData (MEDIUMBLOB).
It apperas that small files (i.e. 10KB upload fine, but anything over about 50 or 60KB fails). I can't give an Error Message because it doesn't return one
I'm not being daft and the file IS there...
I'm probably not doing it right... I've followed tutorials which use the same method (except they do the obviousy adding filesize, and filename etc to other columns..)
Code: Select all
<?php
$conn = mysql_connect('localhost', 'myuser', 'mypass') or die ('Connect failed');
mysql_select_db('chriscor_main') or die ('Select DB failed');
$filebin = file_get_contents('./Shifts.xls');
//I've tried this too
//$filebin = fread(fopen('./Shifts.xls', 'r'), filesize('./Shifts.xls'));
$query1 = "INSERT INTO files (fileData) VALUES ('$filebin')";
$result = mysql_query($query1) or die('Query failed');
mysql_close($conn);
?>