Skip to content

Instantly share code, notes, and snippets.

@recrack
recrack / gist:29dc22b9fb706d6b32ba7d89cd5ac0a4
Created July 21, 2019 09:06 — forked from ssigwart/gist:aa4a2cdf8ffc4024bf89
Simple Redline13 Test Stats API Call
<?php
define('API_ENDPOINT', 'https://www.redline13.com/Api/');
define('API_AUTH_KEY', 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
define('RUN_SIMPLE_LOAD_TEST', true);
// Build POST
$post = array(
'testType' => 'simple',
'name' => 'Simple Test With Name Via API',
@recrack
recrack / media_upload.php
Created July 21, 2019 08:28 — forked from malina-eb/media_upload.php
Make a multipart media upload to S3 using PHP
<?php
$options = array(
'http'=>array(
'method'=>'GET',
'ignore_errors'=>true
)
);
$url = 'https://www.eventbriteapi.com/v3/media/upload/?type=image-event-logo&token=' . getenv('TOKEN');
@recrack
recrack / upload.php
Created July 21, 2019 08:12 — forked from taterbase/upload.php
Simple file upload in php
<!DOCTYPE html>
<html>
<head>
<title>Upload your files</title>
</head>
<body>
<form enctype="multipart/form-data" action="upload.php" method="POST">
<p>Upload your file</p>
<input type="file" name="uploaded_file"></input><br />
<input type="submit" value="Upload"></input>
@recrack
recrack / buildMultipartFormData.php
Created July 21, 2019 08:06 — forked from ncovercash/buildMultipartFormData.php
Build multipart/form-data in PHP
<?php
/**
* Build multipart/form-data
*
* @param array @$data Data
* @param array @$files 1-D array of files where key is field name and value if file contents
* @param string &$contentType Retun variable for content type
*
* @return string Encoded data
*/
@recrack
recrack / __upload_file.md
Created July 21, 2019 07:52 — forked from maxivak/__upload_file.md
PHP upload file with curl (multipart/form-data)

We want to upload file to a server with POST HTTP request. We will use curl functions.


// data fields for POST request
$fields = array("f1"=>"value1", "another_field2"=>"anothervalue");

// files to upload
$filenames = array("/tmp/1.jpg", "/tmp/2.png");;
@recrack
recrack / MultiPartFromStrings.php
Created July 21, 2019 07:52 — forked from iansltx/MultiPartFromStrings.php
Multipart file uploads in PHP from strings
<?php
/**
* PHP's curl extension won't let you pass in strings as multipart file upload bodies; you
* have to direct it at an existing file (either with deprecated @ syntax or the CURLFile
* type). You can use php://temp to get around this for one file, but if you want to upload
* multiple files then you've got a bit more work.
*
* This function manually constructs the multipart request body from strings and injects it
* into the supplied curl handle, with no need to touch the file system.