|
-
Nov 4th, 2008, 01:23 PM
#1
Thread Starter
Hyperactive Member
validating images in php
hi
i have a simple form where the user can enter in a url of an image, and then this image is displayed on a page. as of yet, there is no validation to check the url supplied. obviously i need to fix this. i have a few questions and id like to hear your points:
firstly, i can do a check to see if the url entered ends in jpg/jpeg/gif/png/bmp but is there a more widespread check available? also i would like to check to see if the image even exists, ie. whether its not been removed etc. is there a way to accomplish all this?
secondly, i am allowing users to enter images from anywhere on the net. the images act as links direct to the website they are taken from. in this case i dont think im stealing copyright, however maybe i need to consider bandwidth problems? if i had 100 images from one site, and each time a user comes to my site this loads 100 of those images, then it could be a considerable load. is there a better way around this? i thought of uploading files, but it seems to be a lot of work for such a small part of my site.
thanks for your thoughts and advice,
-
Nov 4th, 2008, 01:58 PM
#2
Re: validating images in php
Here is a function which will check if a file exists on a remote server:
http://www.php.net/manual/en/functio...open.php#39948
It creates a HTTP request for the file, if the server returns 200 OK then it exists, or if it returns 404 Error then it does not exist.
You can add your own code to make it check the extension for .bmp jpg etc.
The only problem you have with using images on other servers is they could be removed/renamed/moved at any time after you have checked it with your function.
-
Nov 4th, 2008, 03:58 PM
#3
Thread Starter
Hyperactive Member
Re: validating images in php
thanks for the link, ill check it out for sure
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|