Title: Image Sync url_get_contents
Last modified: May 11, 2020

---

# Image Sync url_get_contents

 *  Resolved [AzzX](https://wordpress.org/support/users/azzx/)
 * (@azzx)
 * [6 years ago](https://wordpress.org/support/topic/image-sync/)
 * 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 );
    -  This topic was modified 6 years ago by [AzzX](https://wordpress.org/support/users/azzx/).

Viewing 1 replies (of 1 total)

 *  [Elvira K.](https://wordpress.org/support/users/treibalen/)
 * (@treibalen)
 * [6 years ago](https://wordpress.org/support/topic/image-sync/#post-12822339)
 * Hi there!
 * Thank you for your input!
 * I have passed your feedback and suggestion to our development team and they will
   look into it.
 * I’m going to mark this as resolved – if you have any further questions or suggestions,
   you can start a new thread.
 * Cheers!

Viewing 1 replies (of 1 total)

The topic ‘Image Sync url_get_contents’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce-square/assets/icon-256x256.png?rev=3234354)
 * [WooCommerce Square](https://wordpress.org/plugins/woocommerce-square/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce-square/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce-square/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce-square/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce-square/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce-square/reviews/)

## Tags

 * [allow_url_fopen()](https://wordpress.org/support/topic-tag/allow_url_fopen/)
 * [curl](https://wordpress.org/support/topic-tag/curl/)
 * [images](https://wordpress.org/support/topic-tag/images/)

 * 1 reply
 * 2 participants
 * Last reply from: [Elvira K.](https://wordpress.org/support/users/treibalen/)
 * Last activity: [6 years ago](https://wordpress.org/support/topic/image-sync/#post-12822339)
 * Status: resolved