1

I want to make an upload to Cloudup. The API-Dokumentation says that:

POST /items -d 'filename=tobi.jpg&title=Tobi&stream_id=cc3pGD6avN7'

I used PHP and the Code looks like that:

<?php    
    $context = stream_context_create(array(
      'http' => array(
          'method' => "POST",
          'header'  => "Authorization: Basic " . base64_encode("$user:$passwd"),
          'content' => "filename=aNewFilee.jpg&stream_id=$STREAM_ID"
      )
    ));


    // Create a File
    $data = file_get_contents("https://api.cloudup.com/1/items", false, $context);
?>

That work perfectly and the file is create on the cloud space. But the file is "empty". The Documentation says that we must upload the file to AWS S3. So I take respone from the createt file (which include all S3-Config strings) and prepare the code like that:

<form action="$responseUrl" method="post" enctype="multipart/form-data">
  <input type="hidden" name="key" value="$responseKey">
  <input type="hidden" name="AWSAccessKeyId" value="$responsAccessKey">
  <input type="hidden" name="acl" value="public-read">
  <input type="hidden" name="policy" value="$responsePolicy">
  <input type="hidden" name="signature" value="$responseSignature">

  File to upload to S3:
  <input name="file" type="file">
  <br>
  <input type="submit" value="Upload File to S3">
</form>

And here is the Problem: That do not work... How can I upload the file? Thank you!

P.s.: Don't want to use AWS SDK or cURL!

StefMa
  • 3,344
  • 4
  • 27
  • 48

1 Answers1

1

Have a look at this question - Upload a file using file_get_contents. The answer provided as the necessary setup and params that you are missing that need to be sent along with your data.

Community
  • 1
  • 1