Hi,
I have my script running for uploading files into mysql. (small text-files)
It works fine when I do this from another machine, but when I try this local on the IIS/PHP/mysql server, it returns no errors but the mime and filecontents fields are empty!
Here is my script;
<html>
<body>
<?php
if (!isset($submit))
{
?>
<FORM ENCTYPE="multipart/form-data" action="<? echo $PHP_SELF;?>" method=POST>
<INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="1000">
Send this file: <INPUT NAME="userfile" TYPE="file">
<INPUT TYPE="submit" name="submit" VALUE="Send File">
</FORM>
<?
}
else
{
// includes
include("../conf.php");
include("../functions.php");
$errorList = array();
$count = 0;
// open database connection
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");
// select database
mysql_select_db("test") or die ("Unable to select database!");
$file = fopen($userfile, "r");
// Read in the uploaded file
$fileContents = fread($file, filesize($userfile));
// Escape special characters in the file
$fileContents = AddSlashes($fileContents);
$userfile_type = $HTTP_POST_FILES['userfile']['type'];
$userfile_name = $HTTP_POST_FILES['userfile']['name'];
// generate and execute query
$query = "INSERT INTO files (file, name, mime) VALUES('$fileContents','$userfile_name','$userfile_type')";
$result = mysql_query($query) or die ("Error in query: $query. " .
mysql_error());
// print result
echo "<font size=-1>Update successful. <a href=up.php>Go back to the
main menu</a>.</font>";
// close database connection
mysql_close($connection);
}
?>
</body>
</html>
Can someone help me?
regards, Sascha