I'm using JQuery File Upload to upload an excel file to my server. I need to be able to use the PHPSpreadsheet to then read the values from the excel file so that I can import them to the database. Both should happen in the same page. How can I use ajax to automatically run the PHPSpreadsheet code after file is uploaded?
Asked
Active
Viewed 910 times
0
-
we need to see how far you've gone, show some code please – samezedi May 29 '18 at 09:10
-
Specifically, can you post the jQuery uploader code and the PHP code you have so far? – Ismael Miguel May 29 '18 at 09:12
1 Answers
0
During upload, the client side include a URL to server side, (Upload Handler), this server side can include everything you want, for example at client side :
<form id="fileupload" action="../server/php/" method="POST" enctype="multipart/form-data">
you specify the server side on form : action="../server/php/"
On the server side you can handle the upload, and when is finished you can do what you want with !
This is an official example for uploading, you may play with it until you succeed to upload a sample file, then you can implement it at your project :
Client side : https://github.com/blueimp/jQuery-File-Upload/blob/master/test/index.html
Server side : https://github.com/blueimp/jQuery-File-Upload/tree/master/server/php
Good luck !

Albert Einstein
- 7,472
- 8
- 36
- 71

AIT MANSOUR Mohamed
- 809
- 1
- 7
- 20
-
Thank you, so does the action="../server/php" get executed only after the file gets uploaded? – Inception May 29 '18 at 10:18
-
ur welcome, normally when the upload is complet (processed successfully) it will be avaible on server under the global $_FILES. then you can do what you want with. for example : if you want to read the file after the upload you can do smtg like : file_get_contents($_FILES['uploadedfile']['tmp_name']); ... in fact it depends on what you want to do with ! – AIT MANSOUR Mohamed May 29 '18 at 10:45
-
Oh alright. I just want the file to be processed by PHPSpreadsheet so that the data can be processed and used. I'll try it out and let you know if it works. Earlier I tried modifying the UploadHandler.php and it did not work as expected. – Inception May 29 '18 at 10:54