It looks like you're new here. If you want to get involved, click one of these buttons!
...
<script type=\"text/javascript\">
// this is called by uploadify's onComplete callback
function onUploaded(e, q, f, r, d) {
// you can set some form fields here with data that is returned from uploadify - my upload scripts returns (among other things) the fileid of the uploaded file
// so I can submit this with the form, or silently save it via AJAX
$(\"#fileid\").val(r.fileid);
$(\"#filesize\").val(fileObj.size);
$(\"#uploadifyStatus\").replaceWith('<fieldset><legend>File Uploaded</legend><p>'+ fileObj.name + ' (' + fileObj.size + ') uploaded successfully</p></fieldset>');
// do some other stuff here - like remove the iframe so they can't upload again.
$(\"iframe[id='uploadifyFame']\").remove();
// or silently submit the form via AJAX so the updated form fields can be processed...
}
</script>
...
<form action=\"...\" method=\"post\" ...>
... other form fields here ...
<div id=\"uploadifyStatus\"></div>
<iframe id=\"uploadifyFrame\" src=\"upload-iframe.php\" frameborder=\"0\"....></iframe>
<noframes>
<!-- noframes fallback -->
<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"...\" />
<input type=\"file\" name=\"filetoupload\" />
... alt upload button here ....
</noframes>
... other stuff here ...
</form>
....
<!DOCTYPE ... >
<html>
<head>
...
<script type=\"text/javascript\">
$(document).ready(function() {
$(\"#uploadify\").uploadify({
'uploader' : 'uploadify.swf'
,'script' : 'upload.php'
,'cancelImg' : 'cancel.png'
,'sizeLimit' : 500 * 1024 * 1024
,'folder' : '/tmp_files'
,'auto' : false
,'multi' : false
,'buttonText' : 'Browse'
,'fileDataName' : 'uploadedfile'
,'displayData' : 'speed'
,'onComplete' : function(event, queueID, fileObj, response, data) {
// my upload script returns a JSON object in the response
top.onUploaded(event, queueID, fileObj, response, data);
return true;
}
});
});
</script>
</head>
<body>
<fieldset>
<legend>Upload File</legend>
<div id=\"uploadify\">
<h1>Adobe Flash Player plugin is required for file uploads to work.</h1>
<p><a target=\"_blank\" href=\"http://www.adobe.com/go/getflashplayer\"><img src=\"http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif\" alt=\"Get Adobe Flash player\" /></a></p>
</div>
</fieldset>
<input type=\"button\" name=\"START_UPLOAD\" id=\"btnStartUpload\" class=\"button\" onClick=\"$('#uploadify').uploadifyUpload()\" value=\"Upload\" />
<input type=\"button\" name=\"CANCEL_UPLOAD\" id=\"btnCancelUpload\" class=\"button\" onClick=\"$('#uploadify').uploadifyClearQueue()\" value=\"Cancel Upload\" />
</body>
</html>
I had the problem that the upload component did not work with a client of mine on different versions of IE .
This is appearantly due to the way flash works with dynamic flash components located within form tags in internet explorer.
The fix is really easy, but it was really nasty to find the cause...
If your code looks like this :
$("#FileToUpload").uploadify({ ... });
just add a new line after 'uploadifying' the element :
FileToUploadUploader=document.getElementById("FileToUploadUploader");
So you define a javascript global var with the name of your element+"Uploader", and assign the element to it....
That's all there is to it...
act28 said:Update:
After uninstalling my Flash Player (ver 9), and reinstalling the latest Flash Player, it now works in IE... sort of. Now I get a different error... "null" is null or not an object, when it returns from the onComplete callback. If I remove the form tags, it works fine. With the form tags in, it breaks... BUT ONLY ON IE8!!!
So, after much frustration, the workaround I came up with was this:
1. I embedded an iframe inside the form, to call the uploadify script.
2. The uploadify script has no form tags and is essentially setup the same way as the basic samples.
3. onComplete calls a javascript function from the top window containing the form and passes the fileObj and response back to the top window, so that the form knows what was uploaded.
This solution works in both FF3 and IE8.
act28 said:Update:
After uninstalling my Flash Player (ver 9), and reinstalling the latest Flash Player, it now works in IE... sort of. Now I get a different error... "null" is null or not an object, when it returns from the onComplete callback. If I remove the form tags, it works fine. With the form tags in, it breaks... BUT ONLY ON IE8!!!
So, after much frustration, the workaround I came up with was this:
1. I embedded an iframe inside the form, to call the uploadify script.
2. The uploadify script has no form tags and is essentially setup the same way as the basic samples.
3. onComplete calls a javascript function from the top window containing the form and passes the fileObj and response back to the top window, so that the form knows what was uploaded.
This solution works in both FF3 and IE8.
{
$("#uploadify").uploadify({
'uploader' : '/swf/uploadify.swf',
'fileDesc' : 'Type de fichier : MP3 et 10Mo maximum',
'fileExt' : '*.mp3',
'folder' : '/',
'cancelImg' : '/images/cancel.png',
'buttonImg' : '/images/button_parcourir.png',
'width' : '80',
'height' : '27',
'onSelect' : function(){$(".filesupcont").height(350);$(".filesupcont").jScrollPane({showArrows: true, animateScroll: true});},
'onProgress' : function(){ $("#cancelpn").fadeIn("fast");},
'onComplete' : function(){ $("#cancelpn").fadeOut("fast");},
'wmode' : 'transparent',
'onError': function (event, queueID ,fileObj, errorObj) {
var msg;
if (errorObj.status == 404) {
alert('Could not find upload script. Use a path relative to:');
msg = 'Could not find upload script.';
alert(msg);
} else if (errorObj.type === "HTTP"){
msg = errorObj.type+": "+errorObj.status;
alert(msg);
}else if (errorObj.type ==="File Size"){
msg = fileObj.name;
alert(''+errorObj.type+' Limit: '+Math.round(errorObj.sizeLimit/1024)+'KB');
}else{
msg = errorObj.type+": "+errorObj.text;
alert(msg);
return false;
}
},
'buttonText' : 'Choisir',
'onAllComplete' : function(){closefacebox(); document.location='/#/'+lang+'/music/'+nickname+'/newadd:'+daten+''; },
'sizeLimit' : 10000000,
'queueID' : 'fileQueue',
'auto' : false,
'multi' : true
});