Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8574677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:31:38+00:00 2026-06-11T19:31:38+00:00

I have a simple bottle.py app that let’s me upload files. Now since those

  • 0

I have a simple bottle.py app that let’s me upload files. Now since those files can be quite big i wanted to have a progress bar. I found jqUploader which looked to be like just what i wanted but now i have trouble getting it to work.
My upload worked perfectly when i had my own form but now i don’t know how to properly acces the data anymore.

py:

@route('/upload')
def upload():
  return static_file('upload_form.html', root='html')

@post('/load_from_file')
def load_from_file():
  print("Uploading...")
  name = request.forms.name
  data = request.files.myFile3
  print(data)
  filename = data.filename
  with open(os.path.join("C:\\", filename), "wb") as file_object:
      bytes = 0
      while True:
          datachunk = data.file.read(1024)
          if not datachunk:
              break            
          file_object.write(datachunk)
          bytes  += len(datachunk)
  return "Hello %s! You uploaded <b>%s</b>." % (name, filename)

HTML:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>jqUploader demo</title>
    <link rel="stylesheet" type="text/css" media="screen" href="static/style.css"/>
    <script type="text/javascript" src="static/jquery-1.4.4.min.js"></script>
    <script type="text/javascript" src="static/jquery.flash.js"></script>
    <script type="text/javascript" src="static/jquery.jqUploader.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){
            $('#example1').jqUploader({
                debug:0
                ,background:'FFFFDF'
                ,barColor:'FFDD00'
                ,allowedExt:'*.txt; *.xml;'
                ,allowedExtDescr: 'what you want'
                ,validFileMessage: 'Thanks, now hit Upload!'
                ,endMessage: 'and don\'t you come back ;)'
                ,hideSubmit: false
            });
            $("#example2").jqUploader({
                afterScript:    "redirected.php",
                background: "FFFFDF",
                barColor:   "64A9F6",
                allowedExt:     "*.avi; *.jpg; *.jpeg; *.png",
                allowedExtDescr: "Images and movies (*.avi; *.jpg; *.jpeg; *.png)"
            });

            $("#example3").jqUploader({
            background: "FFFFDF"
            ,barColor:  "FF00FF"
            ,allowedExt:'*.txt; *.xml;'
            ,allowedExtDescr: 'what you want'
            ,validFileMessage: 'Thanks, now hit Upload!'
            });
        });
    </script>
</head>
<body>
        <h3>The form</h3>
        <form enctype="multipart/form-data" action="/load_from_file" method="POST" class="a_form">
            <fieldset>
                <legend>Upload your file</legend>
                <ol>
                    <li id="example3">
                        <label for="example3_field">Choose a file to upload:</label>
                        <input name="myFile3" id="example3_field"  type="file" />
                    </li>
                </ol>
            </fieldset>
            <input type="submit" name="submit" value="Upload File" />
        </form>


    </div>
</body>

ERROR:

AttributeError: ‘str’ object has no attribute ‘filename’

Help would be much appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T19:31:40+00:00Added an answer on June 11, 2026 at 7:31 pm

    Here’s the working code (didn’t change anything in the html or js):

    @route('/upload')
    def upload():
        #Upload-Form
        return static_file('upload_form.html', root='html')
    
    @post('/load_from_file')
    def load_from_file():
        #Actual Uploading
        if request.POST.Upload == 'Submit Query':
            try:
                data = request.POST.Filedata.file
                filename = request.POST.Filename
                filepath = os.path.join(settings.FOLDERS["TEMP_WORKING"], filename)
                with open(filepath, "wb") as file_object:
                    while True:
                        datachunk = data.file.read(1024)
                        if not datachunk:
                            break            
                        file_object.write(datachunk)
                process_files_upload(filepath)            
            except:
                print(traceback.format_exc())
            #Check if only uploaded or already finished
            return "Upload Finished"
        else:
            redirect('/upload')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have simple php validation form that is halfway working. If you leave the
I have simple win service, that executes few tasks periodically. How should I pass
I have a relatively simple program that currently uses 1 thread (main). The application
I have a silverlight 3 application, that fetches some simple data from a ms-sql-server
I have a very simple CRUD API: from bottle import get, post, put, delete,
i have simple table with two fields: ID and Date how can i do
I have simple code that does a head request for a URL and then
I have a simple question. How can I search NSMutable Dictionary? For eg. I
Have simple Order - Item app. No cart. Need help with joined scopes for
So i supose that i have a server application written in python import bottle

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.