in Education by
I want to upload the file pdf to the folder but a file is not saved to a folder. I already read the documentation of upload in flask documentation, but a file isn't saved to my folder. I am so confused there's no error from flask import Flask, render_template, request, session, url_for, redirect, flash from werkzeug.utils import secure_filename UPLOAD_FOLDER = 'C:\\Users\\shyfa\\Documents\\Skripsi\\Program Fix\\uploads\\' ALLOWED_EXTENSIONS = ['pdf'] app = Flask(__name__) app.secret_key = "secret key" app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER def allowed_file(filename): return '.' in filename and filename.rsplit('.',1)[1].lower in ALLOWED_EXTENSIONS @app.route("/test", methods=['GET','POST']) def upload_file(): if request.method == 'POST': if 'file' not in request.files: flash('No File Part') return redirect(request.url) file = request.files['file'] if file.filename == '': flash('No Selected File') return redirect(request.url) if file and allowed_file(file.filename): filename = secure_filename(file.filename) file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) return redirect(url_for('upload_file', filename = filename)) return render_template('CobaInput.html') if __name__ == "__main__": app.run(debug=True)``` Select the correct answer from above options

1 Answer

0 votes
by
 
Best answer
You can use the below code but the first mistake is you did is: filename.rsplit('.',1)[1].lower() Do check out Data Science with Python course which helps you understand from scratch

Related questions

0 votes
    I am trying to write my below pinging script results into the Text file, but I am getting an error message. ... object is not iterable Select the correct answer from above options...
asked Jan 11, 2022 in Education by JackTerrance
0 votes
    I am totally new to Machine Learning and I have been working with unsupervised learning technique. Image shows my ... 3 were given Select the correct answer from above options...
asked Feb 1, 2022 in Education by JackTerrance
0 votes
    I have the dataset that has the no_employees column that is the str object. whats is a best way to create the new ... 1-5 |Very Small Select the correct answer from above options...
asked Jan 19, 2022 in Education by JackTerrance
0 votes
    I have a big data frame. I want to replace float 1.0 and 0.0 with the true and false. My code: import pandas ... to do it in one line. Select the correct answer from above options...
asked Jan 19, 2022 in Education by JackTerrance
0 votes
    When I run pip3 install -r requirements.txt on the project I get this error message: pip._vendor.pkg_resources. ... on my machine. Select the correct answer from above options...
asked Jan 19, 2022 in Education by JackTerrance
0 votes
    please see my code below, example_list = [ ['a','b','c'], ['f','g','h'], ['i','j','k'], ] my_string = ''' ' ... g','h'), ('i','j','k'); Select the correct answer from above options...
asked Jan 19, 2022 in Education by JackTerrance
0 votes
    I have the data frame that looks like this: Date Visa Mastercard Amex Paypal 1/1/20 0 20 0 0 2/1/20 ... info() Any help is appreciated Select the correct answer from above options...
asked Jan 19, 2022 in Education by JackTerrance
0 votes
    To the data frame df: Player Team Points Mean Price Value Gameweek 1 Jim Leeds 4.4 4.40 10.44 0.44 2 Jim ... scalar What am I missing? Select the correct answer from above options...
asked Jan 18, 2022 in Education by JackTerrance
0 votes
    A few days ago I've started learning pygame. So, now I've got the code which allows me to draw different ... ) py.display.update() Select the correct answer from above options...
asked Jan 11, 2022 in Education by JackTerrance
0 votes
    SA=1000.00 AI=0.12 MP=100.00 def remainb(x): if x==0: return 0 else: return x=(SA+(AI/12)*SA)-MP for ... . run the loop until SA==0). Select the correct answer from above options...
asked Jan 11, 2022 in Education by JackTerrance
0 votes
    Can anyone tell me what is Python with Data Science? Select the correct answer from above options...
asked Jan 11, 2022 in Education by JackTerrance
0 votes
    I have this following datetime64[ns] type timestamps. x1=pd.Timestamp('2018-04-25 00:00:00') x2=pd.Timestamp('2020- ... -04-25 00:53:00 Select the correct answer from above options...
asked Jan 9, 2022 in Education by JackTerrance
0 votes
    Suppose I have a Tensorflow tensor. How do I get the dimensions (shape) of the tensor as integer values? I ... 'Dimension' instead. Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    While training a tensorflow seq2seq model I see the following messages : W tensorflow/core/common_runtime/gpu/pool_allocator ... GB GPU Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    While training a tensorflow seq2seq model I see the following messages : W tensorflow/core/common_runtime/gpu/pool_allocator ... GB GPU Select the correct answer from above options...
asked Feb 5, 2022 in Education by JackTerrance
...