hi all.
I'm currently using this snippet of code to upload files for a site:
<SCRIPT language="php">
if (file_exists("lib/sessions.lib.php"))
require_once("lib/sessions.lib.php");
else
require_once("../lib/sessions.lib.php");
if (file_exists("lib/mysqlSession.lib.php"))
require_once("lib/mysqlSession.lib.php");
else
require_once("../lib/mysqlSession.lib.php");
function imageUpload($imageUpload, $imageType)
{
/*
Variable Setup
*/
// NOTE: To use this Function, the first argument should be the name of the file field, and NOT the value of the field.
//ex. $largeFile = imageUpload("imageFull","galleryImage");
$imageUpload;
$uploadError = $_FILES[$imageUpload] ['error'];
if ($uploadError == NULL)
$uploadError = 5;
$fileTemp = $_FILES[$imageUpload] ['tmp_name'];
$editfileName = $_FILES[$imageUpload] ['name'];
$fileName = $_FILES[$imageUpload] ['name'];
$fileSize = $_FILES[$imageUpload] ['size'];
$fileType = $_FILES[$imageUpload] ['type'];
$site_name = $_SERVER['HTTP_HOST'];
$url_dir = "http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
$url_this = "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
$upload_url = "../upload/images/";
$ticketRaw = MD5(uniqid(rand(), true));
$ticket = substr($ticketRaw, 5, 10);
/*
Validate File Size
*/
if (($uploadError == 1)||($uploadError == 2)) //Error on filesize detected
print ("<HTML><BODY onload=\"timer=setTimeout('filesizeError()',0)\"></BODY></HTML>\n");
else
//$uploadError = 0;
{
$validateUpload = new MysqlSession();
$validateUploadConnect = $validateUpload->mysqlConnect();
$validateUploadQuery = $validateUpload->mysqlQuery
("
SELECT * from `system\$allowedfiletypes`
WHERE ((`fileTypeValue` = '$fileType') && ((`fileTypeValue` = 'image/bmp') || (`fileTypeValue` = 'image/jpeg')||(`fileTypeValue` = 'image/gif')||(`fileTypeValue` = 'image/png')))
");
$query_total = mysql_num_rows($validateUploadQuery);
if ($query_total != 0)
{
list($width, $height, $type, $attr) = getimagesize($fileTemp);
$fileUp = $upload_url.$fileName;
$fileTemp;
$newFile = "$upload_url"."$ticket-$fileName";
//$newFile = "$ticket-$fileName";
move_uploaded_file($fileTemp,$fileUp);
$editFileName = rename("$fileUp","$newFile");
return $newFile;
}
}
}
</SCRIPT>
Thing is, it only works on Firefox. Under IE, it only accepts .gif files for uploads.
Any suggestions?
Many thanks in advance.