<div dir="ltr">Hi,<div><br></div><div>Can you suggest your upload code and the server error message?</div><div><br></div><div><br></div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Best regards,<div>Ares Ou</div><div><br></div><div><b>Software Engineer / Full-Stack Python Developer</b></div><div><b><br></b></div><div><span style="font-size:12.8px"><b>Blog:</b> </span><a href="http://aresou.net" style="font-size:12.8px" target="_blank">http://aresou.net</a>  |  <span style="font-size:12.8px"><b>Github:</b> </span><a href="https://github.com/aresowj" style="font-size:12.8px" target="_blank">https://github.com/aresowj</a></div><div><span style="font-size:12.8px"><b>Stack Overflow:</b> </span><a href="http://stackoverflow.com/users/5183727/ares-ou" style="font-size:12.8px" target="_blank">http://stackoverflow.com/users/5183727/ares-ou</a></div><div><br></div><div><font color="#ffffff">Ares Ou</font></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>
<br><div class="gmail_quote">On Mon, Nov 14, 2016 at 11:34 PM, Colin Haig <span dir="ltr"><<a href="mailto:colin@techdata.net.au" target="_blank">colin@techdata.net.au</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;color:rgb(0,0,0);font-size:14px;font-family:Calibri,sans-serif"><div><div><div>Hi Dmitry</div><div><br></div><div>I can upload smaller files – it is when the file is above 130k that the problem occurs.</div><div><br></div><div><div>def fnGetFileArea(cDestination):</div><div>    cFileList = ''</div><div>    if sys.platform == 'darwin':</div><div>        cDestination = "/Volumes/documents"</div><div>        session['platform'] = 'mac'</div><div>    elif sys.platform == 'win32':</div><div>        session['platform'] = 'win32'</div><div>        cDestination = "p:\\"</div><div>    return(cDestination)   </div></div><div><br></div><div><div>@app.route('/docget',methods=[<wbr>'GET','POST'])</div><div>def docget():</div><div>    cDocType     = ''</div><div>    cDestination = ''</div><div>    aDocs        = []</div><div>    cFileList    = []</div><div>    srv          = ''</div><div>    if request.method == 'POST':</div><div>        cDestination = fnGetFileArea(cDestination)</div><div>        cUser = request.args.get('user')</div><div>        cUserType = request.args.get('usertype')</div><div>        cDocType = request.form['doctype']</div><div>        session['user'] = cUser</div><div>        if 'attach' in request.files:  </div><div>            file = request.files['attach']</div><div>            filename = file.filename</div><div>            if filename != '':</div><div>                filename = filename.replace(' ','_')</div><div>                if session['platform'] == 'mac':</div><div>                    cFileSaveArea = cUserType + '/' + cDocType</div><div>                    destination = '/'.join([cDestination+'/'+<wbr>cFileSaveArea,filename])</div><div>                    cDestination = cDestination + '/' + cUserType</div><div>                elif session['platform'] == 'win32':</div><div>                    cFileSaveArea = cUserType + '\\' + cDocType</div><div>                    destination = '\\'.join([cDestination+<wbr>cFileSaveArea,filename])</div><div>                    cDestination = cDestination + '\\' + cUserType</div><div>                try:    </div><div>                    cError = file.save(destination) </div><div>                except:</div><div>                      flash('could not save')</div><div>                cFileList = os.listdir(cDestination)</div><div>                return render_template('selectdoc.<wbr>html',user=cUser,usertype=<wbr>cUserType,aDocs=cFileList)</div><div>    else:</div><div>        cDestination = fnGetFileArea(cDestination)</div><div>        if 'user' in request.args:</div><div>            cUser = request.args.get('user')</div><div>            session['user'] = cUser</div><div>        if 'usertype' in request.args:</div><div>            cUserType = request.args.get('usertype')</div><div>        if session['platform'] == 'mac':</div><div>            cDestination = cDestination + '/' + cUserType</div><div>        if session['platform'] == 'win32':</div><div>            cDestination = cDestination + '\\' + cUserType</div><div>        cFileList = os.listdir(cDestination)</div><div>        if cUser .strip() != '' and cUserType.strip() != '':</div><div>            return render_template('selectdoc.<wbr>html',user=cUser,usertype=<wbr>cUserType,aDocs=cFileList)</div></div><div><br></div><div>Have tested on my windows apache server and small files are uploaded but large files fail.</div><div><br></div><div>Regards</div><div><br></div><div>Colin</div><div><br></div><div><br></div><div><div id="m_-6063916196663721787MAC_OUTLOOK_SIGNATURE"></div></div></div></div><div><br></div><span id="m_-6063916196663721787OLK_SRC_BODY_SECTION"><div style="font-family:Calibri;font-size:12pt;text-align:left;color:black;BORDER-BOTTOM:medium none;BORDER-LEFT:medium none;PADDING-BOTTOM:0in;PADDING-LEFT:0in;PADDING-RIGHT:0in;BORDER-TOP:#b5c4df 1pt solid;BORDER-RIGHT:medium none;PADDING-TOP:3pt"><span style="font-weight:bold">From: </span> Flask <<a href="mailto:flask-bounces+colin=techdata.net.au@python.org" target="_blank">flask-bounces+colin=techdata.<wbr>net.au@python.org</a>> on behalf of Dmitry <<a href="mailto:d@ddipp.net" target="_blank">d@ddipp.net</a>><br><span style="font-weight:bold">Date: </span> Tuesday, 15 November 2016 at 2:48 pm<br><span style="font-weight:bold">To: </span> <<a href="mailto:flask@python.org" target="_blank">flask@python.org</a>><br><span style="font-weight:bold">Subject: </span> Re: [Flask] File Upload<br></div><div><br></div><div>
  
    
  
  <div text="#000000" bgcolor="#FFFFFF"><span class="">
    <p><span id="m_-6063916196663721787result_box" lang="en"><span>Check the</span> <span>write
          permissions</span> <span>on the</span> <span>folder in which
          you</span> <span>save the file</span><span>.</span><br>
        <span>When</span> <span>downloading a file</span> <span>passes</span>
        <span>100</span><span>% and</span> <span>then</span> <span>there
          is an error</span><span>, then perhaps</span> <span>it is not
          connected</span> <span>with the limitation</span> <span>on</span>
        <span>size</span><span>.</span><br>
        <span>Or show</span> <span>code</span> <span>that allows</span> <span>to upload files to</span>
        <span>the server</span><span>.</span></span></p>
    <br>
    <div class="m_-6063916196663721787moz-cite-prefix">15.11.2016 11:33, Colin Haig пишет:<br>
    </div>
    </span><blockquote type="cite"><span class="">
      <div>
        <div>
          <div><br>
          </div>
        </div>
      </div>
      <div><br>
      </div>
      <span id="m_-6063916196663721787OLK_SRC_BODY_SECTION">
        <div><br>
        </div>
        <div>
          <div style="word-wrap:break-word;color:rgb(0,0,0);font-size:14px;font-family:Calibri,sans-serif">
            <div>To All </div>
            <div><br>
            </div>
            <div>I am trying to upload a file using flask – but when I
              upload a large file I get a server error.</div>
            <div><br>
            </div>
            <div>I have tried the following :</div>
            <div><br>
            </div>
            <div>
              <div>app.config['MAX_CONTENT_<wbr>LENGTH'] = 16 * 1024 * 1024</div>
            </div>
            <div>When I reduce the above setting Flask reports a 413
              error which is is supposed to do</div>
            <div><br>
            </div>
            <div><br>
            </div>
            <div>Updated apache server</div>
            <div><br>
            </div>
            <div>Have added LimitRequestBody 0  to my http.conf</div>
            <div><br>
            </div>
            <div>If I upload the file though my locahost flask server
              there are no issues.</div>
            <div><br>
            </div>
            <div><br>
            </div>
            <div>When I submit the file upload I can see a counter
              counting up to 100% but then it crashes with a server
              error – I have</div>
            <div>checked the apache logs but can not see any error
              associated with the upload.</div>
            <div><br>
            </div>
            <div>I have searched the web looking for answers but to no
              avail.</div>
            <div><br>
            </div>
            <div>Any help greatly appreciated.</div>
            <div><br>
            </div>
            <div>Regards</div>
            <div><br>
            </div>
            <div>Colin</div>
            <div><br>
            </div>
            <div><br>
            </div>
            <div><br>
            </div>
            <div><br>
            </div>
          </div>
        </div>
      </span>
      <br>
      <fieldset class="m_-6063916196663721787mimeAttachmentHeader"></fieldset>
      <br>
      </span><pre>______________________________<wbr>_________________
Flask mailing list
<a class="m_-6063916196663721787moz-txt-link-abbreviated" href="mailto:Flask@python.org" target="_blank">Flask@python.org</a><a class="m_-6063916196663721787moz-txt-link-freetext" href="https://mail.python.org/mailman/listinfo/flask" target="_blank">https://mail.<wbr>python.org/mailman/listinfo/<wbr>flask</a></pre>
    </blockquote><span class="">
    <br>
    <pre class="m_-6063916196663721787moz-signature" cols="72">-- 
Dmitry Podkovyrkin
email: <a class="m_-6063916196663721787moz-txt-link-abbreviated" href="mailto:d@ddipp.net" target="_blank">d@ddipp.net</a></pre>
  </span></div></div><span class="">
______________________________<wbr>_________________
Flask mailing list
<a href="mailto:Flask@python.org" target="_blank">Flask@python.org</a>
<a href="https://mail.python.org/mailman/listinfo/flask" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/flask</a>
</span></span></div>
<br>______________________________<wbr>_________________<br>
Flask mailing list<br>
<a href="mailto:Flask@python.org">Flask@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/flask" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/flask</a><br>
<br></blockquote></div><br></div>