It looks like you're new here. If you want to get involved, click one of these buttons!
$(document).ready(function() {
var uploadLimit = 2,
uploadCount = 0,
uploadAlert = true,
uploadMsg = 'Sorry but you can only upload '+uploadLimit+' pictures.';
$(\"#fileUpload3\").fileUpload({
'uploader': 'http://domain.com/gears/static/js/uploader.swf',
'cancelImg': 'http://domain.com/gears/static/imgs/cancel.png',
'script': '/gears/',
'scriptData': {'ajax':'1', 'module':'upload'},
'fileExt': '*.jpg;*.jpeg;*.gif;*.png;*.mp3',
//'displayData': 'speed',
//'simUploadLimit': 4,
'folder': 'files',
'fileDesc': 'Image Files',
'multi': true,
'auto': true,
onCancel: function(a, b, c, d){
uploadCount--;
},
onClearQueue: function(a, b){
uploadCount = b.fileCount;
},
onSelect: function(a, b){
if( uploadCount==uploadLimit ){
if( uploadAlert ){
alert(uploadMsg);
uploadAlert = false;
}
return false;
}
else{
uploadCount++;
}
},
onAllComplete:function(){
//your form function call here
//queueSize = 0;
alert('aa');
},
onComplete:function(event, queueID, fileObj, response, data){
//queueSize--;
alert(response);
//alert(response);
alert(fileObj.name);
$('#filesUploaded').text($('#filesUploaded').text()+fileObj.name);
},
onError: function(a, b, c, d)
{
if (d.status == 404)
alert('Could not find upload script. Use a path relative to: '+'');
else if (d.type === \"HTTP\")
alert('error '+d.type+\": \"+d.status);
else if (d.type ===\"File Size\")
alert(c.name+' '+d.type+' Limit: '+Math.round(d.sizeLimit/1024)+'KB');
else
alert('error '+d.type+\": \"+d.text);
}
});
});
</script>var_dump($_FILES);//returns empty array
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = '/var/www/domain.com/gears/';
$targetFile = str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];
// Uncomment the following line if you want to make the directory if it doesn't exist
// mkdir(str_replace('//','/',$targetPath), 0755, true);
move_uploaded_file($tempFile,$targetFile);
}
echo \"1\";
'script': '/gears/upload.php',
<html>
<head>
<title>Test Upload</title>
<link rel=\"stylesheet\" href=\"/css/uploadify.css\" type=\"text/css\" />
<script type=\"text/javascript\" src=\"/js/jquery-1.3.2.min.js\"></script>
<script type=\"text/javascript\" src=\"/js/jquery.uploadify.js\"></script>
<script type=\"text/javascript\">
$(document).ready(function() {
$('#fileInput').fileUpload ({
'uploader': 'images/upload/uploader.swf',
'cancelImg': 'images/upload/cancel.png',
'script' : 'upload.php',
'buttonText': 'Select File',
'auto' : false,
'folder' : 'uploads',
'sizeLimit' : 152476800,
'onComplete': function(event, queueID, fileObj, response, data) {
if(response.substring(0,5) !== \"Error\") {
$('#downloads').append(\"<a href='https://test/download.php?fid=\" + response + \"'>Download \" + fileObj.name + \"</a>\");
} else {
alert(response);
}
}
});
});
</script>
</head>
<body>
<input type=\"file\" name=\"fileInput\" id=\"fileInput\" />
<a href=\"javascript:$('#fileInput').fileUploadStart()\">Start Upload</a> | <a href=\"javascript:$('#fileInput').fileUploadClearQueue()\">Clear Queue</a>
<p></p>
<div id=\"downloads\"></div>
</body>
</html>
...post-processing and DB calls...
// Now for the actual work
if(empty($msg)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$fileName = $_FILES['Filedata']['name'];
$fileType = $_FILES['Filedata']['type'];
$fileSize = $_FILES['Filedata']['size'];
$targetPath = TMP_LOCAL_STORAGE . $fid . '/';
$targetFile = str_replace('//','/',$targetPath) . time() . \"_\" . $userid . \"_\" . $fileName;
if(move_uploaded_file($tempFile, $targetFile))
{
...more DB work here...
$stringData = $fileId;
} else {
$stringData = \"Error: \" . intval($_FILES['Filedata']['error']) . \" Error Info: \" . $msg;
}
} else {
$stringData = \"Error: 1 Error Info: \" . $msg;
}
$data['message'] = \"upload -> \" . $stringData;
Log::logData($data);
echo $stringData;
?>