praveenhotha Posted April 14, 2008 Share Posted April 14, 2008 When I click the browse option, it lists all the files present in the folder but if i cancel after selecting for eg. an html file, the second time I click the browse button, it displays only the html files in the folder. Can I do this on the first click of the browse button? I want to control the files shown as I know what type of files need to be uploaded. Link to comment https://forums.phpfreaks.com/topic/101021-input-typefile-controlling-the-file-type-displayed/ Share on other sites More sharing options...
ToonMariner Posted April 14, 2008 Share Posted April 14, 2008 what ever you want to do - give up - it can be circumvented - the only thing you can do reliably is to check teh mime type of teh uploaded file - if that is ok continue if not tell the user. You can enhacne this with a nasty javascript check to see what the file extension is (but don't actually trust this) - if its not what you expect then you can prevent the upload. Link to comment https://forums.phpfreaks.com/topic/101021-input-typefile-controlling-the-file-type-displayed/#findComment-516588 Share on other sites More sharing options...
praveenhotha Posted April 14, 2008 Author Share Posted April 14, 2008 I am checking the file extension for the file type,presently. Just thought that it might be more user friendly if only one particular type of files are displayed in the dialog(if it is possible). Thanks. Link to comment https://forums.phpfreaks.com/topic/101021-input-typefile-controlling-the-file-type-displayed/#findComment-516592 Share on other sites More sharing options...
PFMaBiSmAd Posted April 14, 2008 Share Posted April 14, 2008 You cannot specify the file type using html/javascript. You can if you use flash - http://www.swfupload.org/ Link to comment https://forums.phpfreaks.com/topic/101021-input-typefile-controlling-the-file-type-displayed/#findComment-516624 Share on other sites More sharing options...
ToonMariner Posted April 14, 2008 Share Posted April 14, 2008 you can use the accept attribute to specify what it should allow but again this cannot be relied upon and I have never used it so don't know how it acts on differing operating systems/browsers indeed I have read that some browsers completely ignore it... <input type="file" accept="image/jpeg, text/css, image/png" /> Link to comment https://forums.phpfreaks.com/topic/101021-input-typefile-controlling-the-file-type-displayed/#findComment-516657 Share on other sites More sharing options...
Zhadus Posted April 14, 2008 Share Posted April 14, 2008 I think what he wants to do is change what "File Type" is defaulted in the dialog box so that the USER doesn't have to sort through a folder full of .wav files when they are looking to upload a .txt file. Is this correct? Link to comment https://forums.phpfreaks.com/topic/101021-input-typefile-controlling-the-file-type-displayed/#findComment-516780 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.