Skip to content

Instantly share code, notes, and snippets.

@sidchilling
Created November 30, 2012 19:19
Show Gist options
  • Save sidchilling/4177891 to your computer and use it in GitHub Desktop.
Save sidchilling/4177891 to your computer and use it in GitHub Desktop.
CURL method to make POST request with file upload
<?php
$url = 'http://localhost/tests/upload_file'; #URL for the service
$file_path = '/home/siddharthsaha/Desktop/production.html'; # File to be uploaded
$data = array(
'owner' => 'siddharth saha',
'test_file' => '@' . $file_path # For files, you have to append a @ before the filepath.
);
# Make the curl request exactly as in the POST example above.
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment