Last active
February 10, 2016 16:25
-
-
Save coolbung/40e04f71fa268cb154f3 to your computer and use it in GitHub Desktop.
Upload files using Joomla JHttp
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
$path = realpath('/absolute/path/to/file.jpg'); | |
$upload_path = new \CURLFile($path); | |
$url = 'http://example.com/upload'; | |
//$post_data['foo'] = 'bar'; | |
$post_data['file'] = $upload_path; | |
//$headers['user-id'] = 'imli'; | |
$headers['Content-Type'] = 'multipart/form-data'; | |
$options = new JRegistry; | |
$http = JHttpFactory::getHttp($options, 'curl'); | |
$op = $http->post( $url, $post_data, $headers ); | |
print_r($op); | |
print_r($http); | |
jexit(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment