Video (Other) download +tomcat configuration code + picture upload limit size

Source: Internet
Author: User

  video Download:
Foreground JSP function Downvideo (value,row,index) {return' <a href= ' <%=basepath%>admin/video/video!filedown.ds?uname= ' +row.uname+ ' &filepath= ' +value+ ' "> download </a> ';} Backstage Java:action: Public voidFiledown () {fileutil.download (filepath, Getrequest (). GetParameter ("Uname") +filepath.substring (Filepath.lastindexof (".")), Filepath.length ()), GetResponse ()); }fileutil: Public Static voidDownload (string filepath, string filename, httpservletresponse response) {Response.setcontenttype ("Application/x-download;charset=utf-8"); OutputStream OUTP=NULL; FileInputStream in=NULL; Try{Response.AddHeader ("Content-disposition", "attachment;filename=" +NewString (Filename.getbytes ("GBK"), "Iso-8859-1")); Inch=NewFileInputStream (Servletactioncontext.getservletcontext (). Getrealpath ("/") +filepath); OUTP=Response.getoutputstream (); } Catch(unsupportedencodingexception E1) {e1.printstacktrace (); } Catch(FileNotFoundException e) {e.printstacktrace (); } Catch(IOException e) {e.printstacktrace (); } byte[] B =New byte[1024]; inti = 0; Try { while((i = in.read (b, 0, 1024))! =-1) {Outp.write (b,0, i); Outp.flush (); } } Catch(IOException e) {e.printstacktrace (); } finally { if(In! =NULL) { Try{in.close (); } Catch(IOException e) {e.printstacktrace (); } in=NULL; } if(OUTP! =NULL) {OUTP=NULL; } } }

Tomcat Configuration code is Utf-8

69th Line in Tomcat Servlet.xml, plus uriencoding= "UTF-8"     <  port= "8080"  protocol= "http/1.1"   uriencoding= " UTF-8 "               connectiontimeout=" 20000 "               redirectport=" 8443 "  />

Image upload Limit size

<formID= "Financialform"Action= "<%=basepath%>riskcontrol/website/review_borrow!financialuplaod.ds"Method= "POST"enctype= "Multipart/form-data"onsubmit= "return Checkusertype ()" >         <inputtype= "hidden"name= "Usreid"value= "<%=_usreId%>" />         <inputtype= "hidden"name= "Borrowid"value= "<%=_borrowId%>" />         <inputtype= "File"name= "image"multiple= "multiple"ID= "Financialimages"/>         <inputtype= "Submit"value= "Start upload"/>    </form>
<script type= "Text/javascript" >functionCheckusertype () {varUsertype= "${login_session_key.usertype}"; if(! (usertype==2| | usertype==11) {alert ("Only financial wind control or HQ customer service can upload review material"); return false; }Else{    returnSubmitfile (); } } functionSubmitfile () {varFilearr = document.getElementById ("Financialimages"). files; if(filearr.length==0) {alert (' Please select the uploaded image! '); return false; }    for(vari=0;i<filearr.length;i++){   varImagename=Filearr[i].name; varExtstart=imagename.lastindexof ("."); varext=imagename.substring (extstart,imagename.length). toUpperCase (); if(ext!= ". PNG "&&ext!=". JPEG "&&ext!=". JPG "&&ext!=". BMP ") {alert ("Image is limited to PNG,JPEG,JPG,BHMP format"); return false; }       varFileSize = filearr[i].size/1024;if(parseint (filesize) >300) {alert (' picture cannot be greater than 300KB '); return false; }     //$ (' #financialForm '). Submit ();   }  }</script>

Video (Other) download +tomcat configuration code + picture upload limit size

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.