witham Posted October 28, 2007 Share Posted October 28, 2007 Hi I am trying o uploa some files into mysql database by keep getting the error message Warning: fread(): supplied argument is not a valid stream resource in C:\Program Files\xampp\htdocs\upload.php on line 4 File ID: 0 File Name: File Size: File Type: To upload another file Click Here I have an html form <form method="post" action="upload.php" enctype="multipart/form-data"> Description:<br> <input type="text" name="form_description" size="40"> <input type="hidden" name="MAX_FILE_SIZE" value="1000000000"> <br>File to upload:<br> <input type="file" name="form_data" size="40"> <p><input type="submit" name="submit" value="submit"> </form> and a php handling script <?php mysql_connect("localhost","root",""); mysql_select_db("database_name"); $data = addslashes(fread(fopen($form_data, "r"), filesize($form_data))); $result=MYSQL_QUERY("INSERT INTO uploads (description, data,filename,filesize,filetype) ". "VALUES ('$form_description','$data','$form_data_name','$form_data_size','$form_data_type')"); $id= mysql_insert_id(); print "<p>File ID: <b>$id</b><br>"; print "<p>File Name: <b>$form_data_name</b><br>"; print "<p>File Size: <b>$form_data_size</b><br>"; print "<p>File Type: <b>$form_data_type</b><p>"; print "To upload another file <a href=http://localhost/upload.html> Click Here</a>"; ?> I have been through the code and seached the forum but can't find a resolution so I would really appreciate some help! Quote Link to comment https://forums.phpfreaks.com/topic/75125-file-upload-error/ Share on other sites More sharing options...
sford999 Posted October 28, 2007 Share Posted October 28, 2007 Where are you passing the file to the upload.php file? I suggest reading about handling files http://uk2.php.net/features.file-upload Quote Link to comment https://forums.phpfreaks.com/topic/75125-file-upload-error/#findComment-379989 Share on other sites More sharing options...
witham Posted October 29, 2007 Author Share Posted October 29, 2007 Thanks for your reply, I missed the database name previously which I have now put in but I still get the message. I also read the link you kindly put up and to be honest being new to php I am not really any wiser as I want to put the data into an database and this explains putting it into a file? Quote Link to comment https://forums.phpfreaks.com/topic/75125-file-upload-error/#findComment-380716 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.