Issue
{{my_salesforce_url}}/sfc/servlet.shepherd/document/download/0694U000007w5QyQAI?operationContext=S1
this url content a file with name ine_file.jpg, when run in browser work and download the file direct, but when i try download with php and save the file in local no work
i try with:
file_put_contents(public_path() . "/" . $fileName, fopen($file["url"], 'r'));
and
file_put_contents(public_path() . "/" . $fileName, file_get_contents($url));
any idea ? How to get a file from url and save the file using php o curl?
Solution
You can try this if you are downloading from a secured server
$options = array(
"ssl" => array(
"verify_peer" => false,
"verify_peer_name" => false,
),
);
$image = file_get_contents('www.example.com/image.jpg', false, stream_context_create($options));
$filename = 'filename.jpg';
$filedir = 'public/uploads/' . $filename;
file_put_contents($filedir, $image);
Answered By - Puneet Karajagi
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.