Skip to content

Instantly share code, notes, and snippets.

@marcinwol
Created January 23, 2011 05:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcinwol/791856 to your computer and use it in GitHub Desktop.
Save marcinwol/791856 to your computer and use it in GitHub Desktop.
Example phpt file for testing file uploads
--TEST--
Example test emulating a file upload
--SKIPIF--
<?php if (php_sapi_name()=='cli') die('skip'); ?>
--POST_RAW--
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryfywL8UCjFtqUBTQn
------WebKitFormBoundaryfywL8UCjFtqUBTQn
Content-Disposition: form-data; name="file"; filename="example.txt"
Content-Type: text/plain
Some file data ....
------WebKitFormBoundaryfywL8UCjFtqUBTQn
Content-Disposition: form-data; name="submit"
Upload
------WebKitFormBoundaryfywL8UCjFtqUBTQn--
--FILE--
<?php
var_dump($_FILES['file']['name']);
?>
--EXPECT--
string(11) "example.txt"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment