fopen - Detect file type of a file using just the URL of file that is on a remote server using PHP when allow_url_fopen is disabled? -


i building php app allows user upload image files server entering url of image on remote server.

stackoverflow has functionality when upload image ask question screen.

my app part of sugarcrm module installed on many servers different configurations , software. reason need build app flexible possible , try account many setups possible.

my biggest hurdle servers have php ini setting allow_url_fopen set false/off limits choices downloading remote files url.

my question more focussed on getting file type of remote file. many sites days serve images without file extension in there url , if can spoofed beleive.

currently how app gets file extension of file on remote server...

$info = @getimagesize($this->remote_image_url); $mime = $info['mime'];  // sort of image? $filetype = substr(strrchr($mime, '/'), 1); 

looking @ php docs getimagesize() says this...

$filename parameter specifies file wish retrieve information about. can reference local file or (configuration permitting) remote file using 1 of supported streams.

(configuration permitting) remote file using 1 of supported streams

this hurdle of allow_url_fopen being turned off on server nightmare!

i can detect status of allow_url_fopen this...

if(ini_get('allow_url_fopen')){     return true; } 

so detect allow_url_fopen on , if use getimagesize() detect file type , when not enabled make sure not call function.


question:
question how can reliably file type of remote file using url access file on server has php ini setting allow_url_fopen turned off?


Comments