Again I have to say sorry for asking the same question:
Notice that this script runs well on my local machine Apache+php+Mysql. But once I uploaded it to my free website,it became useless.
When I executed the following script, I got the following errors:
Warning: fopen("", "r") - No such file or directory in C:\webserver\webservermanager\gigiclub\uploadtest.php on line 7
Warning: fread(): supplied argument is not a valid File-Handle resource in
C:\webserver\webservermanager\gigiclub\uploadtest.php on line 7
My script
---------------------------uploadtest.php----------------------------------
<?php require('config.php'); ?>
<?
//uploadtest.php
global $PHP_SELF,$yourname,$image;
if($submit){
$img = addslashes(fread(fopen($image, "r"), filesize($image)));
$query="insert into mytable values('$yourname','$img')";
$result=mysql_db_query("mydatabase",$query);
if($result)
print("Thank you $yourname,your image file is successfully uploaded");
else
print("Couldn't upload your image file.");
}
else {
print("
<form enctype=multipart/form-data action=$PHP_SELF method=post>
<table><tr><td>Your name<input name=yourname></td></tr>
<tr><td>Your image file<input type=file name=image><input type=submit name=submit
value=submit></td></tr></table></form>");
}
?>
My config.php contains all the info needed connecting to MySQL
database(host,username,password..)
And my sql script is as followed:
create table mytable(yourname varchar(40),image blob);
My problem is that when the fopen / fread command
looks for the tmp folder - it can`t find it. I have even tried adding $image = str_replace("\\\\","\\",$image); (but still not working)
I think there should be some problems with this line:
$img = addslashes(fread(fopen($image, "r"), filesize($image)));
Please help. Thank you.
Regards,
david foo