Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

140
Views
Envíe el archivo usando ajax jquery y léalo en el back-end usando Flask

Estoy tratando de enviar un archivo usando ajax jquery desde el front-end.

HTML

 <label>Upload File </label> <form method='post' enctype="multipart/form-data"> <input type='file' id='uploaded_file'> <button id="submit-file">Submit</submit> </form>

JavaScript

 <script> $(document).ready(function(){ $("#submit-file").click(function(event){ var form_data = new FormData(); form_data.append("uploaded_File_Name","MyFile"); form_data.append("file",$("#uploaded_file").prop('files')[0]); $.ajax({ url:"/read_uploaded_file", type:"POST", contentType: false, cache: false, processData: false, data: form_data, success: function(data){ console.log("Successful data upload"); }, error: function(data){ console.log("Error !!"); } }); }); }); </script>

En el back-end, estoy usando un matraz para leer el archivo.

 @app.route('/read_uploaded_file',method=["GET","POST"]) def read_uploaded_file(): uploaded_file = request.files['file']

Recibo un mensaje de error POST (URL) 405 (MÉTODO NO PERMITIDO) , ¿Estoy haciendo algo mal aquí? ¿Cómo lo arreglo?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

El error POST (URL) 405 (MÉTODO NO PERMITIDO) se debe al intercambio de recursos de origen cruzado (CORS).

Para resolver este CORS agregado en el respaldo:

 from flask_cors import CORS app= Flask(__name__) CORS(app)
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!