Hello,
I am very frustrated and I am missing the point to register globals at least when it comes to uploading files.
If I declare a variable in the code already do I still need to use $GET, $POST to retreive it?
Anyway... My problem lies with the below code works perfectly fine with register globals off. Files are uploaded perfectly fine. When I turn them on everything goes to crap. Any ideas?
if (!($connection = @ mysql_pconnect($hostName,
$username,
$password)))
showerror();
if (!mysql_select_db("ylddb", $connection))
showerror();
// Was a file uploaded?
if (is_uploaded_file($userfile))
{
switch ($userfile_type)
{
case "image/gif";
$_POST['mimeName'] = "GIF Image";
break;
case "image/jpeg";
$_POST['mimeName'] = "JPEG Image";
break;
case "image/png";
$_POST['mimeName'] = "PNG Image";
break;
case "image/x-MS-bmp";
$_POST['mimeName'] = "Windows Bitmap";
break;
default:
$_POST['mimeName'] = "Unknown image type";
}
// Open the uploaded file
$file = fopen($userfile, "r");
// Read in the uploaded file
$fileContents = fread($file, filesize($userfile));
// Escape special characters in the file
$fileContents = AddSlashes($fileContents);
}
else
$fileContents = NULL;
$insertQuery = "INSERT INTO files VALUES (NULL, '2',
'1', '$mimeName', '$fileContents')";
mysql_query($insertQuery, $connection);
print_r($_FILES);
?>