troubleshooting Question

How to append PHP script.

Avatar of edvinson
edvinsonFlag for United States of America asked on
13 Comments1 Solution286 ViewsLast Modified:
I would like to have this simple script tell me when upload has been successful.

<form name="uploader" method="post" action="" enctype="multipart/form-data">
      <input type="file" name="image" style="width:300px;cursor:pointer" />
      <input type="submit" name="upload" value="Upload Image" />



# edit # 
    $maxwidth = 25000; 
    $maxheight = 25000; 
    $max_filesize = 1024000; 

    $uploads = 'uploads'; 
    $types_array = array('image/gif','image/jpeg','image/x-png', 'image/jpg'); 
# end edit # 

if($_FILES['image']['name'] == "") 
    echo "Please select a file to upload!\n"; 

if(!in_array($_FILES['image']['type'], $types_array)) 
    echo "That file type is not allowed!\n"; 

    $max_filesize_kb = ($max_filesize / 102400); 

if($_FILES['image']['size'] > $max_filesize) 
    echo "Your file is too large, files may be up to ".$max_filesize_kb."kb\n"; 

    $imagesize = getimagesize($_FILES['image']['tmp_name']); 

    $imagewidth = $imagesize[0]; 
    $imageheight = $imagesize[1]; 

if($imagewidth > $maxwidth || $imageheight > $maxheight) 
    echo "You file is too large, files may be up to ".$maxwidth."px x ".$maxheight."px in size\n"; 
move_uploaded_file($_FILES['image']['tmp_name'], $uploads.'/'.$_FILES['image']['name']) 
or die ("Couldn't upload ".$_FILES['image']['name']."\n"); 

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 13 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 13 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros