Skip to content

Instantly share code, notes, and snippets.

@paingpyi
Created February 12, 2014 06:49
Show Gist options
  • Save paingpyi/8951045 to your computer and use it in GitHub Desktop.
Save paingpyi/8951045 to your computer and use it in GitHub Desktop.
<?php
$target_path = "uploads/";
$uploadedFiles = array();
/*** check if a file has been submitted ***/
if(isset($_FILES['userfile']['tmp_name']))
{
/** loop through the array of files ***/
for($i=0; $i < count($_FILES['userfile']['tmp_name']);$i++)
{
// copy the file to the specified dir
if(@copy($_FILES['userfile']['tmp_name'][$i],$upload_dir.'/'.$_FILES['userfile']['name'][$i]))
{
$messages[] = $_FILES['userfile']['name'][$i].' uploaded';
}
else
{
/*** an error message ***/
$messages[] = 'Uploading '.$_FILES['userfile']['name'][$i].' Failed';
}
}
}
header("Content-type:text/json");
$json = json_encode(array("message"=>"ok"));
echo $json;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment