PHP Image Upload Question

Soldato
Joined
14 Feb 2006
Posts
4,644
Location
Surrey, UK
I've got a form with a 'File' type input, which submits to:
action="imguploadscr.php"

In that page, I have this:
Code:
if(isset( $Submit ))
{ //If the Submitbutton was pressed do:
if ($_FILES['imagefile']['type'] == "image/jpeg"){ 
// do image processing stuff
} else {
echo "Sorry, only JPEG files are permitted. (".$_FILES['imagefile']['name'].")<br>";
}
}

Now when I upload a small JPG file, for example 200kb, it works fine. However, when I try a file that's big, ie. around 5mb+, it fails, giving the error "Sorry, only JPEG files are permitted", when it is definitely a JPG file.

Anyone got any idea what's going on here?

Thanks,
Jon
 
My apologies. I'm not particularly experienced with PHP/MySQL.

Here is the If statement with the image processing code included:
Code:
if(isset( $Submit ))
{
//If the Submitbutton was pressed do:


if ($_FILES['imagefile']['type'] == "image/jpeg"){ 
global $ticketid;

    copy ($_FILES['imagefile']['tmp_name'], "../images/".$ticketid.".jpg") 
    or die ("Could not copy");        
	echo ""; 
        echo "Name: ".$_FILES['imagefile']['name'].""; 
        echo "<br>Size: ".$_FILES['imagefile']['size'].""; 
        echo "<br>Type: ".$_FILES['imagefile']['type'].""; 
        echo "<br><br><b>Thanks, your photo has been submitted. Your Ticket ID is: ".$ticketid.".";
	echo "<br>You can check your ticket status <a href='../tickets/ticketinforeq.php'>here</a>.";
	echo "<br><br>";
	$picpath = "../images/".$ticketid.".jpg";
	echo "<a href='".$picpath."' target='_blank'><img src='".$picpath."' height=150></a>";
	echo "<br><i>Preview. Click to view full size.</i>";

//update database to show a pic has been sent

$username="root";
$password="youwish";
$database="printdb";

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$query="UPDATE tickets SET photosub='1' WHERE ticketno='$ticketid'";
mysql_query($query);

$query="UPDATE tickets SET printsize='".$papersize."' WHERE ticketno='$ticketid'";
mysql_query($query);
$query="UPDATE tickets SET printmedium='".$medium."' WHERE ticketno='$ticketid'";
mysql_query($query);
$query="UPDATE tickets SET printframed='".$frame."' WHERE ticketno='$ticketid'";
mysql_query($query);

mysql_close();
 
        } else {
            echo "<br><br>";
            echo "Sorry, only JPEG files are permitted. (".$_FILES['imagefile']['name'].")<br>";
        }
}

Thanks,
Jon
 
Sorted! Thanks Sic, it was the filesize limit. I thought I'd changed it, but apparently I hadn't!

Thanks again,
Jon
 
Back
Top Bottom