I am asking the user to upload a file, through the following form making a POST Request to another page Upload.php
<form name="input" action="upload.php" method="post" enctype="multipart/form-data">
Username: <input type="text" name="username" /><br/>
<input type="file" name="file" /> <br/>
<input type="submit" value="Submit" />
</form>
At Upload.php, I use the data filled in the previous form to make an POST Request using Curl function for which I have written the following code:
$data = array(
"username" => $username,
"password" => $password,
"title" => $title,
"srcfile" => "@".$_FILES['file']['tmp_name']);
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_URL, $api);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$response=curl_exec($ch);
echo $response;
This way I am able to upload the file successfully but the file uploaded has a name without any extension which is set by this
$_FILES['file']['tmp_name']
and thus I am not able to use the file on the server.
How should I use the file obtained from the POST Request to make another POST Request?
Thanks in advance.