hi,
im trying to implement a file upload in windows, with IIS, php and mysql, but i keep having problems.
it seems that the form loses the filename.
Can you help me. Thanks
my code is this
<?
GLOBAL $upfile;
extract($_POST, EXTR_OVERWRITE);
if (@$submit)
{
echo "in <br>";
echo $text;
$mysql_server="localhost";
$mysql_username="root";
$mysql_password="";
$mysql_database="image";
//connect to database using above settings
@MYSQL_CONNECT("localhost",$mysql_username,$mysql_password);
@mysql_select_db($mysql_database);
$imagedata = addslashes(fread(fopen($upfile, "r"), filesize($upfile)));
$imagetype = $upfile_type;
// IMAGE INSERT
$result=MYSQL_QUERY("INSERT INTO ads (bin_data, filetype, description) "." VALUES (".$imagedata .", ".$imagetype.", ".$text.")");
// $result=MYSQL_QUERY("INSERT INTO ads (description) "." VALUES (".$text.")");
MYSQL_CLOSE();
}
else
{
?>
<form action="upfile.php" enctype="multipart/form-data" method="POST">
<input type="file" name="upfile" size="57">
<input type="text" name="text">
<input type="submit" name="submit" value="submit">
</form>
struture of database
phpMyAdmin MySQL-Dump
version 2.4.0
#
Host: localhost
Generation Time: Aug 14, 2003 at 06:04 PM
Server version: 4.0.12
PHP Version: 4.3.2
Database : image
--------------------------------------------------------
#
Table structure for table ads
CREATE TABLE ads (
id varchar(15) default NULL,
description varchar(255) default NULL,
bin_data longblob,
filename longblob,
filesize varchar(50) default NULL,
filetype varchar(50) default NULL,
link varchar(255) default NULL,
shownno int(5) default NULL,
clickcount int(5) default NULL,
UNIQUE KEY id (id)
) TYPE=MyISAM;
this is the output
in
qwerty --> what i typed in the form
Warning: fread(): supplied argument is not a valid stream resource in E:[Calvin.Server.Web]\Viana\ex\upfile.php on line 23
Notice: Undefined variable: upfile_type in E:[Calvin.Server.Web]\Viana\ex\upfile.php on line 24
<?
}
?>