无法上传大文件 [英] Not able to upload large files

查看:59
本文介绍了无法上传大文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想上传大量图像文件(最大10mb) 为此,我正在使用以下配置为struts.xml

I would like to upload large amount of image file (max size 10mb) for that I am using following configuration is struts.xml

<interceptors>
    <interceptor-stack name="fileUploadStack">
        <interceptor-ref name="exception" />
        <interceptor-ref name="alias" />
        <interceptor-ref name="servletConfig" />
        <interceptor-ref name="prepare" />
        <interceptor-ref name="i18n" />
        <interceptor-ref name="chain" />
        <interceptor-ref name="debugging" />
        <interceptor-ref name="profiling" />
        <interceptor-ref name="scopedModelDriven" />
        <interceptor-ref name="modelDriven" />
        <interceptor-ref name="fileUpload">
            <param name="maximumSize">10485760</param>
            <param name="allowedTypes">image/jpg,image/jpeg,image/gif,image/png,image/pjpeg</param>
        </interceptor-ref>
        <interceptor-ref name="checkbox" />
        <interceptor-ref name="staticParams" />
        <interceptor-ref name="actionMappingParams" />
        <interceptor-ref name="params">
            <param name="excludeParams"> dojo\..*,^struts\..*</param>
        </interceptor-ref>
        <interceptor-ref name="conversionError" />
        <interceptor-ref name="validation">
            <param name="excludeMethods"> input,back,cancel,browse</param>
        </interceptor-ref>
        <interceptor-ref name="workflow">
            <param name="excludeMethods"> input,back,cancel,browse</param>
        </interceptor-ref>
    </interceptor-stack>
</interceptors>
   <action name="ownmessageswithimage" class="social.action.UserMessages" method="insertImage">
    <result name="success">/pages/profile/userSingleMessage.jsp</result>
    <result name="input">/pages/errorpages/ajaxError.jsp</result>
    <result name="login">/pages/pleaselogin.jsp</result>
</action>

这是我的jsp文件代码

This is my jsp file code

     <script  type="text/javascript" src="js/jquery.form.js"></script>
        <form id="own_message_post" action="ownmessageswithimage" method="post"> 
            <input id="fileupload" type="file" name="user_post_image"  data-url="ownmessages" />
<textarea name="message"  rows="4" cols="45" id="text_message_status" 
                  ></textarea><br>
                    <input type="submit" value="Post" id="submit_form_button" 
                   style="background:#004091;padding: 2px 20px 2px 20px;color: whitesmoke;font-weight: bold" />
        </form>
        <script type="text/javascript">
            $('#own_message_post').ajaxForm(function(data) {

                $('#fileupload').val("");

            }); 
        </script>

我正在使用malsup异步文件上传脚本 但是问题是它没有上传最大10 mb的大文件. 如何使其成为可能.

I am using malsup asynchronous file upload script But problem is that it is not uploading large file up to 10 mb. How to make it possible.

推荐答案

您应将常量添加到配置文件中,以允许多部分内容的大小最大为10M

You should add the constant to configuration file to allow multipart content size up to 10M

<constant name="struts.multipart.maxSize" value="10485760"/>

这篇关于无法上传大文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆