Hello, I am trying to make a file upload portal. I have the php
portion working. What I am now trying to do is have a blockUI pop up
while the files are being uploaded. Below are my two files. Any help
or direction is greatly appreciated. I have so far been able to make
the blockUI message pop up and it just hangs there or I can make it
upload the files but the blockUI never pops up. If you look you will
see lots of commented out things as I have tried various approach's.
You will also see, I am very new to jQuery/PHP programming. :)
THank you!
upload.php
#############
<html>
<head>
<title>ADRC File Upload</title>
<script src="/jQuery/jquery-1.2.6.js" type="text/javascript"
language="javascript"></script>
<script src="/jQuery/jquery.blockUI.js" type="text/javascript"
language="javascript"></script>
<script src="/jQuery/jquery.MultiFile.js" type="text/javascript"
language="javascript"></script>
<script src="/jQuery/jquery.form.js" type="text/javascript"
language="javascript"></script>
<script type="text/javascript">
// prepare Options Object
var options = {
url: 'doUpload.php',
success: function() {
alert('Thanks you!');
}
};
// pass options to ajaxForm
$('#ADRCform').ajaxForm(options);
// unblock when AJAX activity stops
//$().ajaxstop($.unblockUI({onUnblock: function(){ alert('Thank
you!'); }}));
// create a block function
function block()
{
$.blockUI({
message: '<img src="jQuery/ajax-loader.gif" alt="" /
><h1>Uploading...</h1>',
css: {
border: 'none',
background: 'none'
}
})
}
// $().ajaxStart($.blockUI).ajaxStop($.unblockUI);
// wait for the DOM to be loaded
$(document).ready(function() {
$('#ADRCform').ajaxForm(function () {
$().ajaxStart($.blockUI).ajaxStop($.unblockUI);
//block();
//setTimeout(function() { uploadFiles(); }, 100);
});
});
</script>
</head>
<body>
<form id="ADRCform" action="" method="post" enctype="multipart/
form-data">
<p>Referal Files:
<input type="file" class="multi" name="ADRC_Files[]" />
<input id="doUpload" action="" type="submit" value="Send" />
<input id="testBlock" type="button" value="Click ME" />
</p>
</form>
</body>
</html>
#################
doUpload.php
#################
<?php
include 'upload.php';
foreach ($_FILES["ADRC_Files"]["name"] as $key => $value)
{
$tmp_name = $_FILES["ADRC_Files"]["tmp_name"][$key];
$name = $_FILES["ADRC_Files"]["name"][$key];
$unique_token =date("YmdHis");
$final_name = $unique_token."_".$name;
if(move_uploaded_file($tmp_name,
"/home/wwcweb/FileTransfer/
$final_name"))
{
echo "YES!!";
}
}
?>