michaelkirby Posted April 19, 2010 Share Posted April 19, 2010 Hi all, I'm looking to introduce a file download into my website but not really sure how to go about it. Anyone got any good pointers? Thanks Quote Link to comment Share on other sites More sharing options...
ScotDiddle Posted April 19, 2010 Share Posted April 19, 2010 michaelkirby, Use javascript to allow only specific file-types... The following code limits downloads to your server to images only... The onBlur prevents users from typing in anything into the input box... HTML: <form id="frontFile" name="frontFile"> <input class="style11" onChange="TestFileType(this.form.frontFile.value, ['gif', 'jpg', 'png', 'bmp', 'jpeg']);" id=frontFileImage name=frontFileImage onKeyDown="this.blur(); alert('Use Browse Button !');" onContextMenu="return false;" type="file" /><br /> </form> JavaScript: function TestFileType( fileName, fileTypes ) { if (!fileName) return; dots = fileName.split(".") //get the part AFTER the LAST period. fileType = "." + dots[dots.length-1]; return (fileTypes.join(".").indexOf(fileType) != -1) ? none() : alert("Please only upload files that end in types: \n\n" + (fileTypes.join(" .")) + "\n\nPlease select a new file and try again."); } Hope this helps... Scot L. Diddle, Richmond VA Quote Link to comment Share on other sites More sharing options...
ignace Posted April 19, 2010 Share Posted April 19, 2010 The following code limits downloads to your server to images only... No it doesn't I can just remove all those extra lines and upload any file I want (using FireBug). Disabling JavaScript even does the trick. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.