allowedExtensions = array(); // all files types allowed by default // Specify max file size in bytes. $uploader->sizeLimit = null; // Specify the input name set in the javascript. $uploader->inputName = "qqfile"; // matches Fine Uploader's default inputName value by default // If you want to use the chunking/resume feature, specify the folder to temporarily save parts. $uploader->chunksFolder = "chunks"; $method = get_request_method(); $randomid = $_REQUEST['randomid']; if (!(strlen($randomid) > 0)) { $randomid = $_GET['randomid']; } if (!(strlen($randomid) > 0)) { $randomid = $_POST['randomid']; } // This will retrieve the "intended" request method. Normally, this is the // actual method of the request. Sometimes, though, the intended request method // must be hidden in the parameters of the request. For example, when attempting to // delete a file using a POST request. In that case, "DELETE" will be sent along with // the request in a "_method" parameter. function get_request_method() { if (isset($_POST["_method"]) && $_POST["_method"] != null) { return $_POST["_method"]; } return $_SERVER["REQUEST_METHOD"]; } if ($method == "POST") { header("Content-Type: text/plain"); // Assumes you have a chunking.success.endpoint set to point here with a query parameter of "done". // For example: /myserver/handlers/endpoint.php?done if (isset($_GET["done"])) { $result = $uploader->combineChunks("../var/tmp"); } // Handles upload requests else { // Call handleUpload() with the name of the folder, relative to PHP's getcwd() $result = $uploader->handleUpload("../var/tmp"); // To return a name used for uploaded file you can use the following line. $result["uploadName"] = $uploader->getUploadName(); } // Salva os arquivos que foram enviados num .txt com o randomId $randomFileName = '/tmp/file_upload_' . $randomid . '.txt'; if (file_exists($randomFileName)) { $formerContent = json_decode(file_get_contents($randomFileName)); $formerContent[] = $result; file_put_contents($randomFileName, json_encode($formerContent)); } else { file_put_contents($randomFileName, json_encode(array($result))); } echo json_encode($result); } // for delete file requests else if ($method == "DELETE") { $result = $uploader->handleDelete("../var/tmp"); // Retira o arquivo que foi removido do .txt com o randomId $randomFileName = '/tmp/file_upload_' . $randomid . '.txt'; if (file_exists($randomFileName)) { $formerContent = json_decode(file_get_contents($randomFileName)); foreach ($formerContent as $keyContent => $content) { if ($result['success'] && ($result['uuid'] == $content->uuid)) { unset($formerContent[$keyContent]); } } file_put_contents($randomFileName, json_encode(array_values($formerContent))); } echo json_encode($result); } else { header("HTTP/1.0 405 Method Not Allowed"); } ?>