Reputation: 3424
I am currently using <input type="file">
to post a file. Since I cant specify the value for
<input id="content" type="file">
and have to manually browse for the file, I want to know if I can specify the path using PHP Curl.
will the server read $_POST["content"]
Upvotes: 0
Views: 1183
Reputation: 246
Yes you can do it this way:
$post_params = array();
$post_params['file'] = '@'.'demo/testfile.txt';
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_params);
the @ is really important to specify that this is an actual file to curl
You will receive the file through the $_FILES super global as if you did a rel form
$_FILES['file']
Hope it helps
To answer your question you need the absolute path on your filesystem
Upvotes: 1