I'm using this plugin JQUERY UPLOAD FILE and everything is ok with the uploads I'm adding create function directory and upar inside them but I am not able to pass the variable php id to the page that makes the service my code is like this:
pageenviar.php
$id = $_GET['id'];
if(is_dir("../imagens/$id")) {
echo "diretorio ja existe";
}
else {
mkdir ("../imagens/$id", 0700 );
echo "diretorio criado";
}
<div id="mulitplefileuploader">Upload</div>
$(document).ready(function()
{
var settings = {
url: "upload.php?id=<?php echo $id ?>",
dragDrop:true,
fileName: "myfile",
allowedTypes:"jpg,png,gif,doc,pdf,zip",
returnType:"json",
onSuccess:function(files,data,xhr)
{
// alert((data));
},
showDelete:true,
deleteCallback: function(data,pd)
{
for(var i=0;i<data.length;i++)
{
$.post("uploadDelete.php",{op:"delete",name:data[i]},
function(resp, textStatus, jqXHR)
{
//Show Message
$("#status").append("<div>File Deleted</div>");
});
}
pd.statusbar.hide(); //You choice to hide/not.
}
}
var uploadObj = $("#mulitplefileuploader").uploadFile(settings);
});
upload.php
$id = $_GET['id'];
$output_dir = "../imagens/$id";
if(isset($_FILES["myfile"]))
{
$ret = array();
$error =$_FILES["myfile"]["error"];
//You need to handle both cases
//If Any browser does not support serializing of multiple files using FormData()
if(!is_array($_FILES["myfile"]["name"])) //single file
{
$fileName = $_FILES["myfile"]["name"];
move_uploaded_file($_FILES["myfile"]["tmp_name"],$output_dir.$fileName);
$ret[]= $fileName;
}
else //Multiple files, file[]
{
$fileCount = count($_FILES["myfile"]["name"]);
for($i=0; $i < $fileCount; $i++)
{
$fileName = $_FILES["myfile"]["name"][$i];
move_uploaded_file($_FILES["myfile"]["tmp_name"][$i],$output_dir.$fileName);
$ret[]= $fileName;
}
}
echo json_encode($ret);
}
How to pass the variable?