If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

creating images using the GD thing

I am trying to build an image upload script, but am running into a few issues.
Once the images are uploaded, im trying to determine the type by looking at the format, and to simply copy the image using all those if statements things, is this right?

I would avoid relying on the file extension because you can't really count on there being one all the time since neither Macs nor Windows systems require file name extensions. It's very unlikely that you would run into a graphics file without an extension, but it's always best to use a method that returns the MIME-type such as the one used in the example code that Nick posted:

$_FILES['imageFieldName']['type']

and check for values like "image/png", etc. to determine the appropriate imagecreatefrom() function as you're doing now. It's just one less thing to worry about if you ever run into problems. Good luck!

I am curious nogdog why do you suggest limiting your self to a JPEG instead of an array allowing multiple image types?

Because the application I wrote that for only accepted JPEGs (for whatever reason), and I didn't feel like editing the code here (i.e.: was too lazy) to make it more inclusive. I figured I'd just point y'all in the general direction and let you decide what you want to accept/reject. You could just check for false if all you want to do is verify it's some sort of image that GD recognizes, or you could use in_array() with a list of possible types to allow.

"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