I am working on a SugarCRM module that will be using the PageDown
MarkDown library which is what StackOverflow uses for it's editor.
The open source version that ships does not have the full functionality of the Upload Image feature that StackExchange sites have added on.
This is an improtant feature to me so I am adding it on for my project. I need the Upload Image Dialog window to allow the user to upload an image from there computer as well as be able to upload an image by simply entering the URL of an image online, most likely from a remote server.
When the URL is entered instead of uploading from a users computer, it needs to still fetch and save the image locally just as if it were uploaded to the local server. This has many benefits such as...
- Prevents your users from hotlinking images
- Ensures you have a reliable copy of the image in your application even if the remote source image goes offline. This is important for Forums and such, which is where I will be using this! In my modules customs Discussion Forums section.
- Allows you to re-size and optimize the image if you choose, so that it has the same look and feel and capability as all the other images added to your application from the "Upload from Computer" field. When viewing an image that was uploaded from the "Upload from Computer" or from the "Upload from URL" you will be able to ensure they get the same processing and appear how you like and not different from each other.
So that was stating the obvious. So the real consideration and important factor here is ensuring that the method I used to fetch and save images from remote servers, is a method that is available for use on as many servers as possible.
The reason is, my module is a SugarCRM module which will be used by many people on a whole range of LAMP servers running SugarCRM.
So here are the methods that I know/think might be a solution so far...
I have no idea about how reliable these both are and how good the odds of them being available on the most amount of servers that will be running the PHP SugarCRM software.
I just remember in past experience that I have worked on some client servers, generally shared-hosting where the function I was using that did similar actions, like fetching a URL or something or downloading or something of that nature would not work as the function was not available by default on the server.
So my list of 2 candidates for a good method to download/save remote images using only a URL to a local server in PHP is small and unknown how well either of them are.
I am all ears as to any other methods and the pros and cons of any of these or others and the most likely to succeed in my task?
I found a similar question on StackOverflow here but it doesn't have any answers really... what is the most reliable method to get a file from remote server in php