i don't know what did gone wrong on but this is frustrating, plz help
today i was working on a php script that uploads the images and makes a thumbnails out of them..
well, i had the idea, i wrote the outline then i finished the script
i had a couple of syntax errors and i fixed them,,
but still there's some thing wrong with the code, no image was uploaded and no thumbnail created !!
$image_location = "images/featured/"; // images directory $thumbs_location = "images/tn/"; // thumnails directory $thumbs_width = 100; // width in pixels $maximum_size = 99999999999999; // maximum size in kb (i know, but 99999999999999 looks pretty ) $result ="click browse to locate the image you want to upload"; // just a message bro.
else{ $size=filesize($_FILES['image']['tmp_name']); $filename = stripslashes($_FILES['image']['name']); $extension = get_image_extension($filename ); if ($size > $maximum_size) { $result = "image is too large, please choose a smaller one.";}
else // now checks the extension.. if (($extension != "jpg") && // not a jpg ($extension != "jpeg") && // not a jpeg ($extension != "png") && // not a png ($extension != "gif")) { // not a gif !! WTF is it ??? $result = "it's not an image file, please choose an image with proper extension";}
else // you finally reached this (else) and the image will be uploaded Hallelujah
{ create_thumbnail ($images_location.$image_random_name,$thumbs_location.$image_random_name, $thumbs_width) ; $result = "image has been uploaded"; // it actually refers to me } }
} echo "$result"; ?>
<html> <head> <title>Multi_uploader with thumbnails</title> </head>
<body> <form action="multi_uploader_with_thumbnails.php" method="POST" encypte="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="99999999999999"> <!-- this is kb but 99999999999999 looks cool --> <input type="file" name="image" multiple="multiple" /> <input name="submit" id="submit" type="submit" value="Upload them"> </form>
When I write a script, I normally write it a bit at a time because I test as I go along. The process: Write a little bit. Test. Fix problems (if any). Move on.
Also, I check for more than just syntax errors, I check that the script is, thus far, working as I intended it.
I do this because it's easier to find a bug in a little bit of code than it is in a whole wall of code where it could be hiding out anywhere.
Hope this tip helps you in the future.
As for what's wrong...I'm not going to attempt to answer because I am only an intermediate at PHP and there are advanced programmers here who can (and most likely will) answer. I try to stick to really simple problems because I'm more apt to give a good answer.
The better I get at programming, the more I appreciate arrays. Handy dandy things they are.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Bookmarks