Hello,I'm getting errors trying to locate the PHP temporary folder:
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
Originally I would like to upload the
image file to MySQL database, the following script works well when I tested it on my home pc:
<?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 understanding is that :
a simple HTML file upload form uploads the file to the
server`s temporary folder then issues a variable
indicating the directory path
this path is used in the fopen command to locate the
uploaded file, gather the data to submit to the
database.
My problem is that when the fopen / fread command
looks for the tmp folder - it can`t find it. Something wrong with the code?