• 大小: 7KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-12
  • 语言: 其他
  • 标签: jsp  

资源简介

使用smartupload可以简单地实现图片上传下载

资源截图

代码片段和文件信息

package smartupload;

import java.io.ByteArrayInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.math.BigInteger;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.servlet.ServletException;

public class SmartFile
{
    private SmartUpload m_parent;
    private int m_startData;
    private int m_endData;
    private int m_size;
    private String m_fieldname;
    private String m_filename;
    private String m_fileExt;
    private String m_filePathName;
    private String m_contentType;
    private String m_contentDisp;
    private String m_typeMime;
    private String m_subTypeMime;
    //private String m_contentString;
    private boolean m_isMissing;
    public static final int SAVEAS_AUTO = 0;
    public static final int SAVEAS_VIRTUAL = 1;
    public static final int SAVEAS_PHYSICAL = 2;

    SmartFile()
    {
        m_startData = 0;
        m_endData = 0;
        m_size = 0;
        m_fieldname = ““;//new String(““);
        m_filename = ““;//new String();
        m_fileExt = ““;//new String();
        m_filePathName = ““;//new String(““);
        m_contentType = ““;//new String();
        m_contentDisp = ““;//new String();
        m_typeMime = ““;//new String();
        m_subTypeMime = ““;//new String();
        //m_contentString = ““;//new String();
        m_isMissing = true;
    }

    public void saveAs(String s) throws IOExceptionSmartUploadException
    {
        saveAs(s0);
    }

    public void saveAs(String sint i) throws IOExceptionSmartUploadException
    {
        //Method invokes dubious new String() constructor; just use ““
        //Creating a new java.lang.String object using the no-argument constructor wastes memory because the object so created will be functionally indistinguishable from the empty string constant ““.\u00A0 Java guarantees that identical string constants will be represented by the same String object.\u00A0 Therefore you should just use the empty string constant directly.
        //String s1 = new String();
        String s1 = ““;
        s1 = m_parent.getPhysicalPath(si);
        if(s1 == null)
        {
            throw new IllegalArgumentException(“There is no specified destination file (1140).“);
        }
        try
        {
            java.io.File file = new java.io.File(s1);
            FileOutputStream fileoutputstream = new FileOutputStream(file);
            fileoutputstream.write(m_parent.m_binArraym_startDatam_size);
            fileoutputstream.close();
        }
        catch(IOException ioexception)
        {
            throw new SmartUploadException(“File can‘t be saved (1120).“);
        }
    }

    public void fileToField(ResultSet resultsetString s) throws ServletExceptionIOExceptionSmartUploadExceptionSQLException
    {
        long l = 0L;
        int i = 0x10000;
        int j = 0;
        int k = m_startData;
        if(resultset 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       7012  2016-12-15 15:19  smartupload\SmartFile.java

     文件       1619  2016-12-15 15:19  smartupload\SmartFiles.java

     文件       1985  2016-12-15 15:19  smartupload\SmartRequest.java

     文件      27294  2016-12-15 15:19  smartupload\SmartUpload.java

     文件        154  2016-12-27 15:51  smartupload\SmartUploadException.java

     目录          0  2017-01-05 09:40  smartupload

----------- ---------  ---------- -----  ----

                38064                    6


评论

共有 条评论