Is there a way to accomplish this? The reason is because I’m trying to create an API right now (following the REST tutorial I found here) to be used by a mobile application being developed. I wanted to test file uploads and I tried doing this through curl.
$tempName = $_FILES['upload']['tmp_name']; $serviceUrl = 'api link'; $curl = curl_init($serviceUrl); $curl_post_data = array( "UserFileupload[filename]" => '@' . $tempName, ); curl_setopt($curl, CURLOPT_USERPWD, $username . ":" . $password); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $curl_post_data); $curl_response = curl_exec($curl); curl_close($curl);
The API sees the file fine, but the problem is that I put in rules to only allow certain file types and the name of the file is being set to “something.tmp”, instead of the actual filename. Tmp isn’t part of the allowed file types and so I’m not able to get past validation.