24. april 2004 - 11:12
#2
Du skal have tak for din indsats :D Men jeg kan altså ikke få det til at virke... :'(
Den siger fejl på linie 23:
"Warning: fread(): supplied argument is not a valid stream resource in /customers/fellatia.dk/fellatia.dk/httpd.www/blob/store.php on line 23"
Koden ser lige ledes ud:
<html>
<head><title>Store binary data into SQL Database</title></head>
<body>
<?php
// code that will be executed if the form has been submitted:
if ($_GET['page'] == 'upload') {
// connect to the database
// (you may have to adjust the hostname,username or password)
MYSQL_CONNECT("localhost","***","***");
mysql_select_db("***");
$data = addslashes(fread(fopen($_POST['form_data'], "r"), filesize($_POST['form_data'])));
$result=MYSQL_QUERY("INSERT INTO binary_data (description,bin_data,filename,filesize,filetype) ".
"VALUES ('$_POST[form_description]','$data','$_POST[form_data_name]','$_POST[form_data_size]','$_POST[form_data_type]')");
$id= mysql_insert_id();
print "<p>This file has the following Database ID: <b>$id</b>";
MYSQL_CLOSE();
} else {
// else show the form to submit new data:
?>
<form method="post" action="store.php?page=upload" enctype="multipart/form-data">
File Description:<br>
<input type="text" name="form_description" size="40">
<input type="hidden" name="MAX_FILE_SIZE" value="1000000">
<br>File to upload/store in database:<br>
<input type="file" name="form_data" size="40">
<p><input type="submit" name="submit" value="submit">
</form>
<?php
}
?>
</body>
</html>
Nogle der kan hjælpe?
24. april 2004 - 11:13
#3
Linie 23 er denne linie:
$data = addslashes(fread(fopen($_POST['form_data'], "r"), filesize($_POST['form_data'])));