I saw that AnonFiles allows a user to upload files directly to his account using their API: https://anonfiles.com/docs/api
I created an account and they gave me a API key, and with this key I can upload straight into my account by appending for example ?token=c9516efd61XXXXXX
to the upload request.
I now want a simple form with PHP code that allows me to pick a file and upload it to my anonfiles account.
Here is my code, would you please advise what I am doing wrong, when I click Send I get no response back from anonfiles.
if(isset($_POST['submit']))
{
$attachment = chunk_split(base64_encode(file_get_contents($_FILES['file']['tmp_name'])));
$filename = $_FILES['file']['name'];
$url = 'https://anonfiles.com/api/upload?token=c9516efd61XXXXXX;
$myvars = 'myvar1=' . $attachment . '&myvar2=' . $filename;
$ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_POST, 1);
curl_setopt( $ch, CURLOPT_POSTFIELDS, $myvars);
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt( $ch, CURLOPT_HEADER, 0);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec( $ch );
echo $response;
}
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
<p><br /><label for="file"><span class="fs20"><span class="ff1 cf0" style="color:black;">File: </span></span></label> <input type="file" name="file" id="file"></p>
<p><br /><input type="submit" name="submit" id="submit" value="Send"></p>
</form>