Say that I have an upload form on one of my web pages, how do I validates that all the files uploaded are images files only?(gif & jpg) And how do I specifly a maxium size in kbyte?
Well, getimagesize() has always done it for me. Just run a checker on the image, and then use, say, $img for the type (index 2 is the type). Not sure about kb size, but a read might do it... Poke around, and here's the getimagesize() page: http://www.php.net/manual/en/function.getimagesize.php
So what would the code look like say I only want gif and jpeg file with max. size 500 x 500? And I don't want people to upload files other than gif and jpeg... for example if people are trying to upload a html doc. how do I reject them but let them have jpeg or gif?
It depends on what you need. Do you just want to find out if two values are the same, or do you want to know if they are the same and the same type? I wrote a mini-tutorial here with an example of each, which might help you decide
I have got another question here... I just want to allow people to upload images on my site, now it works fine but I MUST set the pemission to 777... is that very dangerous? I mean, peole can easily write another PHP on their website to massively upload files and viruses to that folder right? Is there anyway that I can make it so only my script can upload files to that folder? Thank you!
Then why is that people saying it is not good setting it to 777?
i guess cuz ppl could upload files to your folder which are on the same server (unless safe_mode is on). dunno if that's really the "problem" with the 777 stuff, but it would be a very good reason to not use 777 on shared / paid hosts. imagine you've got 500 mb webspace and someone with a small account like 50 mb could upload 100 mb files to your folder by knowing the absolute path, but like said before dunno if that's the reason.