Learn Uploadify Dynamic File Extension
Requirement: To change the file extension depending on the value of a dropdown box. The code will explain how this can be achieve. <s...
https://www.czetsuyatech.com/2010/12/web-uploadify-dynamic-file-extension.html
Requirement: To change the file extension depending on the value of a dropdown box.
The code will explain how this can be achieve.
Note: Need to link with jquery.js
The code will explain how this can be achieve.
<script type="text/javascript"> $(document).ready(function() { var fileExt = ""; var fileDesc = ""; var leftSelected = $("#categories option:selected"); if(leftSelected.val() == "PRI") { fileExt = "*.jpg;*.jpeg;*.gif;*.doc;*.docx;*.pdf"; fileDesc = "Allowed Files (.JPG, .JPEG, .GIF, .DOC, .DOCX, .PDF)"; } else if(leftSelected.val() == "AUD") { fileExt = "*.mp3;*.wav"; fileDesc = "Allowed Files (.MP3, .WAV)"; } else if(leftSelected.val() == "VID") { fileExt = "*.flv;*.mpg;*.mp4;*.avi"; fileDesc = "Allowed Files (.FLV, .MPG, .MP4, .AVI)"; } else if(leftSelected.val() == "SMS") { fileExt = "*.html,*.htm,*.doc;*.docx;*.pdf"; fileDesc = "Allowed Files (.HTML, .HTM, .DOC, DOCX, PDF)"; } $('#custom_file_upload').uploadify({ 'uploader' : "uploadify.swf", 'script' : "uploadify.php", 'cancelImg' : "cancel.png", 'checkScript' : "uploadifycheck.php", 'folder' : "", 'pagePath' : "", 'multi' : true, 'auto' : false, 'fileExt' : fileExt, 'fileDesc' : fileDesc, 'queueID' : 'custom-queue', 'queueSizeLimit' : 5, 'displayData' : 'percentage', 'scriptData' : {'categories': $('#categories').val()}, //send a post variable in uploadify.php 'onSelectOnce' : function(event,data) { $('#status-message').text(data.filesSelected + ' files have been added to the queue.'); }, 'onAllComplete' : function(event,data) { $('#status-message').text(data.filesUploaded + ' files uploaded, ' + data.errors + ' errors.'); location.reload(); } }); </script>
Note: Need to link with jquery.js
Post a Comment