开发者

How can I make the browsing file upload window to show only the .jpg images?

I have a form that allow image uploading. However my code until now is not limited to images.

Please let me know how can I do this (maybe with a javascript alert box on submit) or my best solution is to let the browsing window to show onl开发者_如何学Pythony jpg gif and png images instead of the default "All files".

Thanks!

<input name="images[]" value="" type="file" class="textfield" />


You cannot control what is shown in the browser's file upload form. The best option is to implement some client or server side validation on the file's extension.


You can use JavaScript to validate the file extension, also you must validate in server side.

Another option is you can try SWFUpload- a flash JS library for uploading files. It has a feature to validate files type and file sizes before uploading to server. http://swfupload.org/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜