0
am using this plugin JQUERY UPLOAD FILE and it is all ok with the upload I am increasing function of creating directory and upar inside them however I am not able to pass the variable id of php to the page that makes the service my code is so:
php page
$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?
Whenever I read Java when someone refers to Javascript, my eyes hurt. :(
– Guilherme Nascimento