i can upload an image in firefox and i just tested it in ie and for some reason i just get the error saying the file is too large. but i think that is the error that is displayed if nothing gets uploaded. i am unsure why it doesnt work in ie any ideas would be helpful:
<?php
$max_size=2*1024*1024;
// Check if a file has been uploaded
if(isset($_FILES['uploaded_file']) && preg_match("/image\/jpeg|image\/jpg/i",$_FILES['uploaded_file']['type']) && $_FILES['uploaded_file']['size']<= $max_size)
{
// Make sure the file was sent without errors
if($_FILES['uploaded_file']['error'] == 0)
{
$target_path = "images/";
$target_path = $target_path . basename( $_FILES['uploaded_file']['name']);
if(!file_exists($target_path)){
if(move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $target_path))
{
// --- IMPORTANT --- //
$image = $target_path;
$maxHeight = 100; $maxWidth = 90;
include 'thumbnail_function.php'; // Include the function file
thumbnail($image, $maxWidth, $maxHeight); // Call the function with a width of 90...
$maxWidth = 500; $maxHeight = 400; // Redefine the size.
include 'view_function.php';
viewed($image, $maxWidth, $maxHeight); // Call the function again with a width of 350...
// --- IMPORTANT --- //
echo "The file ". basename($_FILES['uploaded_file']['name']). " has been uploaded";
$dbLink = new mysqli('host', 'database', 'username', 'password');
if(mysqli_connect_errno()) {
die("MySQL connection failed: ". mysqli_connect_error());
}
// Gather all required data
$name = $dbLink->real_escape_string($_FILES['uploaded_file']['name']);
$mime = $dbLink->real_escape_string($_FILES['uploaded_file']['type']);
$size = intval($_FILES['uploaded_file']['size']);
$image_path = $dbLink->real_escape_string($target_path);
$gallery_type = $dbLink->real_escape_string($_POST['gallery_type']);
$desc = $dbLink->real_escape_string($_POST['description']);
$image_path = $dbLink->real_escape_string($target_path);
$thumb_path = $dbLink->real_escape_string($tmb_name);
$viewed_path = $dbLink->real_escape_string($viewed);
//query to insert the data i had gathered into the database
$query = "INSERT INTO `images` (`name`, `size`, `created`, `image_path`, `gallery_type_id`, `description`, `thumbnail_path`, `viewed_path`)
VALUES ('{$name}', {$size}, NOW(), '{$image_path}', '{$gallery_type}', '{$desc}', '{$tmb_name}', '{$viewed}')";
//executes the query
$dbLink->query($query);
}
}
else
{
echo '<h1>Error</h1>';
echo 'A file with the same name exists please change the file name and try again';
}
}
else
{
echo '<h1>Error</h1>';
echo 'A file was not sent to the database';
}
}
else
{
echo '<h1>Error</h1>';
echo 'The file is too large. Please upload an image no larger than 2mb';
}
// Echo a link back to the main page
echo '<p>Click <a href="member-index.php">here</a> to go back</p>';
?>
thanks for reading