General developer forum

How to stop re-uploading of files on reload ?

 
Picture of Amrata Ramchandani
How to stop re-uploading of files on reload ?
Group Plugin developers
Following is the process I am doing on CSV File Upload.

 $cir = new csv_import_reader($iid, 'uploaduser');

1) Open $cir->init();

2) Process 

3) Close  $cir->close();

4) Cleanup $cir->cleanup();

5) View the Result

Once the result is being displayed,if  I accidentally reload the page,the file is getting processed again,which shouldn't happen.It should remove the file on cleanup isnt't it ? How do i don the proper cleanup to avoid re-processing of previously uploaded file on page reload ?



 
Average of ratings: -
Picture of Neill Magill
Re: How to stop re-uploading of files on reload ?
Group Core developersGroup Particularly helpful MoodlersGroup Plugin developers

One of the ways Moodle avoids this is by doing something like:

1) Open $cir->init();

2) Process 

3) Close  $cir->close();

4) Cleanup $cir->cleanup();

5) Automatically redirect the user to the results page.

Then refreshing the page will not cause any data to be resubmitted.

 
Average of ratings: -