获取前台jsp页面上传图片的尺寸

jsp:

  <tr id="filetr" class="">
                        <td class="col1 must"><s:text name="msg.portalMS.nodeResource.file.label"/></td>
                        <td>
                            <input type="text" id="txtFileName" name="fileName" readonly="readonly"/>
                            <s:file name="resources"  contentEditable="false" onchange="$('#txtFileName').val(this.value)" onclick="this.blur()" style="outline:none;position:absolute;filter:alpha(opacity=0);-moz-opacity:0;width:10px; top:0px;" />
                            <input type="button" value="<s:text name='msg.portalMS.jsp.file.browse' />"  onmousemove=" $('input:file[name=resources]').css({ top: (event.clientY-10)+'px', left: (event.clientX-14)+'px',outline:'none' })"/> <span></span>
                            <input type="button" onclick="addRow();" value="<s:text name="msg.portalMS.directorymanagement.resource.addmode"/>" style="width: 66px;height: 20px;margin-top: 5px;padding: 0;"/>
                            <span id="fileErr" style="padding:0;color:red"><s:fielderror name="fileError"/></span>
                            <font color='gray'>&nbsp;<s:text name="msg.portalMS.busRecContentmanagement.recommend.uploadFile.valid" /></font>
                        </td>
                    </tr> 

java:

                    FileInputStream is = null;  

                    is = new FileInputStream(upload);  
           
                    BufferedImage   sourceImg = null;  
            
                    sourceImg = javax.imageio.ImageIO.read(is);  
                    long w =  sourceImg.getWidth() ;
                    long h = sourceImg.getHeight();

你可能感兴趣的:(获取前台jsp页面上传图片的尺寸)