Image Sync url_get_contents
-
Currently setting up Squareup for a client and noticed images don’t sync due to the allow_url_fopen requirement. I haven’t seen this usage in code in years due to the exploitative capabilities of turning this on for php. Mosts hosts have this off by default.
An alternative that works using curl but would be great to have it as standard.
Function:
function url_get_contents ( $url ) { if ( ! function_exists( 'curl_init' ) ) { die( 'The cURL library is not installed.' ); } $ch = curl_init(); curl_setopt( $ch, CURLOPT_URL, $url ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); $output = curl_exec( $ch ); curl_close( $ch ); return $output; }
Usage:
$remote_file_data = url_get_contents( $image_url );
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Image Sync url_get_contents’ is closed to new replies.