Last active
May 28, 2023 20:10
-
-
Save bcls/2c9bc400278f3cbdfe1420bac1f23fe1 to your computer and use it in GitHub Desktop.
PHP PUT file #php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$file = fopen($file_on_dir_not_url, "rb"); | |
$curl = curl_init(); | |
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 2); | |
curl_setopt($curl, CURLOPT_HEADER, false); | |
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($curl, CURLOPT_BINARYTRANSFER, true); | |
curl_setopt($curl, CURLOPT_URL, $url); | |
curl_setopt($curl, CURLOPT_PUT, true); | |
curl_setopt($curl, CURLOPT_INFILE, $file); | |
curl_setopt($curl, CURLOPT_INFILESIZE, filesize($file_on_dir_not_url)); | |
$result = curl_exec($curl); | |
curl_close($curl); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment