IIS File Upload_issueRSS

3 replies

Last post Dec 03, 2019 10:09 AM by vk1097

  • IIS File Upload_issue

    Oct 18, 2019 09:17 AM|vk1097|LINK

    Hi Guys,

    I've developed a python web application for uploading files which is working fine in local system. In our office environment, we have a windows remote server where we use IIS to create a site and deploy it. So we can access that webpage in our local environment.
    The issue is when i upload a file from my local environment, im getting below error
    File not uploaded 400 Bad Request: The browser (or proxy) sent a request that this server could not understand.

    I'm trying for the past 2 days to fix this but no luck. Could you guys help to fix this issue.

    Do i need to change add anything in web.config file (or) any permissions related ?



  • Re: IIS File Upload_issue

    Oct 18, 2019 07:07 PM|lextm|LINK

    Lex Li
    IIS Consulting Services at https://support.lextudio.com/services/consulting.html
    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: IIS File Upload_issue

    Oct 21, 2019 03:26 AM|Jalpa Panchal|LINK


    Could you share your file upload code?  what is the file size which you are trying to upload? try to upload the smaller size of the file. 

    You could refer this below link:





    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue.
    If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
  • Re: IIS File Upload_issue

    Dec 03, 2019 10:09 AM|vk1097|LINK

    Sorry Jalpa for late reply.

    Here's my python upload code:

    app.config['ALLOWED_EXTENSIONS'] = set(['xlsx', 'xls', 'csv', 'xlsm', 'mp4'])

    def allowed_file(filename):
         return ('.' in filename) and (filename.rsplit('.', 1)[1] in app.config['ALLOWED_EXTENSIONS'])

    @app.route('/uploader', methods=['POST'])
    def uploader():
        if request.method == 'POST':
          uploaded_file = request.files.getlist('file'); 
          invalid_filenames = []
          correct_filenames = []
          for f in uploaded_file:
              fileName = secure_filename(f.filename)
              if f and allowed_file(f.filename):
                    f.save(os.path.join(upload_folder_path, fileName)) 
          if len(invalid_filenames) == 0:
              return render_template('showFiles.html', filenames=correct_filenames)
              return ','.join(invalid_filenames)
          except Exception as e:
            return 'File not uploaded {}'.format(e)

    My HTML code:

    <form action="/uploader" method="post" enctype="multipart/form-data">
    <input type="file" multiple="" name="file">
    <input type="submit">

    This piece of code works fine when i run in my ide. But when the same setup is deployed in IIS, im getting below error:

    File not uploaded 400 Bad Request: The browser (or proxy) sent a request that this server could not understand.

    File im uploading is less than 2 mb