Saving Images to folder | PHP

ali1

New Member
I want to be able to open the provided URL (which is done via a form) that is an URL that will allow the server to save the file into a directory, for example:\[code\]http://www.google.co.uk/intl/en_com/images/srpr/logo1w.png\[/code\]I want to save that logo into this directory:\[code\]img/logos/\[/code\]Then it will add it to the database by giving it a random file name before so, e.g. \[code\]827489734.png\[/code\]It will now be inserted to the database with the following:\[code\]img/logos/827489734.png\[/code\]I do not want to use cURL for this, I like to work with fopen, file_get_contents, etc...Cheers.EDIT\[code\]$logo = safeInput($_POST['logo']);if(filter_var($avatar, FILTER_VALIDATE_URL)){ $get_logo = file_get_contents($logo); $logo_directory = 'img/logos/'; $save_logo = file_put_contents($logo_directory, $logo); if($save_logo) { $logo_path = $logo_directory . $save_logo;\[/code\]A part of this code I need helping...
 
Back
Top