Hello people, I could really use your help on this one... I have script
to upload image data to a database, but all that is uploaded is the
decription, not the data BLOB itself. There must be something wrong
with the code that fread() and fopen() the file, but what?
The inclusion file below, which diplays the form:
<?php
print ("<table>");
print ("<tr>");
print ("<td><form method=POST action=xhandlea anbod.php
enctype=multipa rt/form-data>");
print ("Omschrijving: ");
print ("</td>");
print ("<td><input type=text name=form_descr iption1 size=25>");
print ("</td>");
print ("</tr>");
print ("<tr>");
print ("<td><input type=hidden name=MAX_FILE_S IZE value=1000000>" );
print ("Bestand:") ;
print ("</td>");
print ("<td><input type=file name=form_data1 size=25>");
print ("</td>");
print ("</tr>");
print ("</table>");
?>
And handling it, I use 5 of these includes, numbered accordingly
<?
$data1 = addslashes(frea d(fopen($form_d ata1, "r"),
filesize($form_ data1)));
$data2 = addslashes(frea d(fopen($form_d ata2, "r"),
filesize($form_ data2)));
$data3 = addslashes(frea d(fopen($form_d ata3, "r"),
filesize($form_ data3)));
$data4 = addslashes(frea d(fopen($form_d ata4, "r"),
filesize($form_ data4)));
$data5 = addslashes(frea d(fopen($form_d ata5, "r"),
filesize($form_ data5)));
$query = "INSERT into $Tabelnaam &
#40;description 1,bin_data1,fil ename1,filesize 1,filetype1,des cription2,bin_d ata2,
filename2,files ize2,filetype2, description3,bi n_data3,filenam e3,filesize3,fi letyp
e3,description4 ,bin_data4,file name4,filesize4 ,filetype4,desc ription5,bin_da ta5,f
ilename5,filesi ze5,filetype5) values ('$form_descrip tion1',
'$form_data1', '$form_data1_na me', '$form_data1_si ze',
'$form_data1_ty pe', '$form_descript ion2', '$form_data2',
'$form_data2_na me', '$form_data2_si ze', '$form_data2_ty pe',
'$form_descript ion3', '$form_data3', '$form_data3_na me',
'$form_data3_si ze', '$form_data3_ty pe', '$form_descript ion4',
'$form_data4', '$form_data4_na me', '$form_data4_si ze',
'$form_data4_ty pe', '$form_descript ion5', '$form_data5',
'$form_data5_na me', '$form_data5_si ze', '$form_data5_ty pe')";
?>
Then I get all these warmings, an entry is made to the database, but
the data BLOB fields in there remain empty:
Something tells me there should be more to it to read and upload a
filem, but don't know what it is...
Thanks!
to upload image data to a database, but all that is uploaded is the
decription, not the data BLOB itself. There must be something wrong
with the code that fread() and fopen() the file, but what?
The inclusion file below, which diplays the form:
<?php
print ("<table>");
print ("<tr>");
print ("<td><form method=POST action=xhandlea anbod.php
enctype=multipa rt/form-data>");
print ("Omschrijving: ");
print ("</td>");
print ("<td><input type=text name=form_descr iption1 size=25>");
print ("</td>");
print ("</tr>");
print ("<tr>");
print ("<td><input type=hidden name=MAX_FILE_S IZE value=1000000>" );
print ("Bestand:") ;
print ("</td>");
print ("<td><input type=file name=form_data1 size=25>");
print ("</td>");
print ("</tr>");
print ("</table>");
?>
And handling it, I use 5 of these includes, numbered accordingly
<?
$data1 = addslashes(frea d(fopen($form_d ata1, "r"),
filesize($form_ data1)));
$data2 = addslashes(frea d(fopen($form_d ata2, "r"),
filesize($form_ data2)));
$data3 = addslashes(frea d(fopen($form_d ata3, "r"),
filesize($form_ data3)));
$data4 = addslashes(frea d(fopen($form_d ata4, "r"),
filesize($form_ data4)));
$data5 = addslashes(frea d(fopen($form_d ata5, "r"),
filesize($form_ data5)));
$query = "INSERT into $Tabelnaam &
#40;description 1,bin_data1,fil ename1,filesize 1,filetype1,des cription2,bin_d ata2,
filename2,files ize2,filetype2, description3,bi n_data3,filenam e3,filesize3,fi letyp
e3,description4 ,bin_data4,file name4,filesize4 ,filetype4,desc ription5,bin_da ta5,f
ilename5,filesi ze5,filetype5) values ('$form_descrip tion1',
'$form_data1', '$form_data1_na me', '$form_data1_si ze',
'$form_data1_ty pe', '$form_descript ion2', '$form_data2',
'$form_data2_na me', '$form_data2_si ze', '$form_data2_ty pe',
'$form_descript ion3', '$form_data3', '$form_data3_na me',
'$form_data3_si ze', '$form_data3_ty pe', '$form_descript ion4',
'$form_data4', '$form_data4_na me', '$form_data4_si ze',
'$form_data4_ty pe', '$form_descript ion5', '$form_data5',
'$form_data5_na me', '$form_data5_si ze', '$form_data5_ty pe')";
?>
Then I get all these warmings, an entry is made to the database, but
the data BLOB fields in there remain empty:
Warning: fopen("", "r") - Success in /xhandleaanbod.p hp on line 100
Warning: stat failed for (errno=2 - No such file or directory) in
/xhandleaanbod.p hp on line 100
Warning: fread(): supplied argument is not a valid File-Handle resource
in /xhandleaanbod.p hp on line 100
Warning: fopen("", "r") - No such file or directory in
/xhandleaanbod.p hp on line 101
Warning: stat failed for (errno=2 - No such file or directory) in
/xhandleaanbod.p hp on line 101
Warning: fread(): supplied argument is not a valid File-Handle resource
in /xhandleaanbod.p hp on line 101
Warning: fopen("", "r") - No such file or directory in
/xhandleaanbod.p hp on line 102
Warning: stat failed for (errno=2 - No such file or directory) in
/xhandleaanbod.p hp on line 102
Warning: fread(): supplied argument is not a valid File-Handle resource
in /xhandleaanbod.p hp on line 102
Warning: fopen("", "r") - No such file or directory in
/xhandleaanbod.p hp on line 103
Warning: stat failed for (errno=2 - No such file or directory) in
/xhandleaanbod.p hp on line 103
Warning: fread(): supplied argument is not a valid File-Handle resource
in /xhandleaanbod.p hp on line 103
Warning: fopen("", "r") - No such file or directory in
/xhandleaanbod.p hp on line 104
Warning: stat failed for (errno=2 - No such file or directory) in
/xhandleaanbod.p hp on line 104
Warning: fread(): supplied argument is not a valid File-Handle resource
in /xhandleaanbod.p hp on line 104
De opdracht is:
1
De opdracht is met succes uitgevoerd!
Warning: stat failed for (errno=2 - No such file or directory) in
/xhandleaanbod.p hp on line 100
Warning: fread(): supplied argument is not a valid File-Handle resource
in /xhandleaanbod.p hp on line 100
Warning: fopen("", "r") - No such file or directory in
/xhandleaanbod.p hp on line 101
Warning: stat failed for (errno=2 - No such file or directory) in
/xhandleaanbod.p hp on line 101
Warning: fread(): supplied argument is not a valid File-Handle resource
in /xhandleaanbod.p hp on line 101
Warning: fopen("", "r") - No such file or directory in
/xhandleaanbod.p hp on line 102
Warning: stat failed for (errno=2 - No such file or directory) in
/xhandleaanbod.p hp on line 102
Warning: fread(): supplied argument is not a valid File-Handle resource
in /xhandleaanbod.p hp on line 102
Warning: fopen("", "r") - No such file or directory in
/xhandleaanbod.p hp on line 103
Warning: stat failed for (errno=2 - No such file or directory) in
/xhandleaanbod.p hp on line 103
Warning: fread(): supplied argument is not a valid File-Handle resource
in /xhandleaanbod.p hp on line 103
Warning: fopen("", "r") - No such file or directory in
/xhandleaanbod.p hp on line 104
Warning: stat failed for (errno=2 - No such file or directory) in
/xhandleaanbod.p hp on line 104
Warning: fread(): supplied argument is not a valid File-Handle resource
in /xhandleaanbod.p hp on line 104
De opdracht is:
1
De opdracht is met succes uitgevoerd!
filem, but don't know what it is...
Thanks!
Comment