- Home
- Forum
- JavaScript - EJ 2
- File Uploader - Remove File different behavior
File Uploader - Remove File different behavior
Hi support,
when I want to remove a file after uploading, the control works in two different ways
a) removing a file right after uploading it (without refreshing the page)
The request sent to the server is:
------WebKitFormBoundary27ouPDMhdgVXAJOD
Content-Disposition: form-data; name="UploadFiles"; filename="test2.pdf"
Content-Type: application/pdf
b) removing a file after leaving the page and coming back or refreshing the page
The request sent to the server is:
------WebKitFormBoundary6jq3Boehk6I623F6
Content-Disposition: form-data; name="UploadFiles"
test2.pdf
This makes it very difficult to write the backend code.
Please help.
Regards,
Stephan
SIGN IN To post a reply.
7 Replies
1 reply marked as answer
JM
Jeyanth Muthu Pratheeban Sankara Subramanian
Syncfusion Team
August 3, 2020 12:50 PM UTC
Hi Stephan ,
Greetings from Syncfusion support.
Before proceeding your query, can you please provide the information below to help us understand the requirement further?
1. Are you using preload files or enable persistence property in your application?
2. Can you share video which demonstrates the issue.
3. Code snippet of the Uploader rendering part.
Regards,
Jeyanth.
SS
Stephan Schrade
August 3, 2020 09:18 PM UTC
Hi suipport,
the code is nothing special, its just from your example in the docs.
// Initialize the control by preload files
var uploadObj = new ej.inputs.Uploader({
asyncSettings: {
saveUrl: 'Url::base(false)?>/file/filesave',
removeUrl: 'Url::base(false)?>/file/fileremove',
},
multiple: false,
files: $filesJS ?>,
uploading: onFileUpload,
removing: onFileRemove,
dropArea: dropElement
});
uploadObj.appendTo('#fileupload');
function onFileRemove(args) {
// removeFile = [];
// args.cancel = true;
args.customFormData = [{'= Yii::$app->request->csrfParam; ?>' : '= Yii::$app->request->csrfToken; ?>'}];
// removeFile.push(args.filesData);
// dialog.show();
}
function onFileUpload(args) {
// add addition data as key-value pair.
args.customFormData = [
{'= Yii::$app->request->csrfParam; ?>' : '= Yii::$app->request->csrfToken; ?>'},
{'filefolderid' : = $filefolderid ?>},
];
}
A video would be too long as you have to go to the developer console of the browser to examine the request parameters.
As I told you before, two different requests are sent depending on the way the remove action is triggered.
These following results are from the developer console of firefox:
First case:
Removing the file directly after uploading it (without refreshing the page).
It looks like the first request (from uploading the file) is resend but to a different url.
The console says the request parameters are::
-----------------------------20552003275751002131175567001
Content-Disposition: form-data; name="UploadFiles"; filename="test2.pdf"
Content-Type: application/pdf
%PDF-1.7
%äãÏÒ
3 0 obj
<>
stream
Content-Disposition: form-data; name="UploadFiles"; filename="test2.pdf"
Content-Type: application/pdf
%PDF-1.7
%äãÏÒ
3 0 obj
<>
stream
...
...
etc till end of pdf file
Second case:
The console says the request parameters are:
Removing the file after refreshing the page manually:
-----------------------------428142423628998047754271717332
Content-Disposition: form-data; name="UploadFiles"
2020_LRVBW_Aufsichtspflichtübertragung_Druck.pdf
-----------------------------428142423628998047754271717332
Content-Disposition: form-data; name="_csrf"
7TFst_OcuQeXn58XIT9vN7jKPZRggt65n6TF66BBACaIf1zixvjLSN7u1HRDYARg8rxU8wrPkNrP6KPZxR5pXA==
-----------------------------428142423628998047754271717332--
Content-Disposition: form-data; name="UploadFiles"
2020_LRVBW_Aufsichtspflichtübertragung_Druck.pdf
-----------------------------428142423628998047754271717332
Content-Disposition: form-data; name="_csrf"
7TFst_OcuQeXn58XIT9vN7jKPZRggt65n6TF66BBACaIf1zixvjLSN7u1HRDYARg8rxU8wrPkNrP6KPZxR5pXA==
-----------------------------428142423628998047754271717332--
This looks very different to me.
Regards,
Stephan
JM
Jeyanth Muthu Pratheeban Sankara Subramanian
Syncfusion Team
August 4, 2020 03:43 PM UTC
Hi Stephan,
Thanks for your update.
We have checked the reported issue based on the two cases mentioned. Unfortunately, we could not find any difference in the request on removing the file. We have demonstrated this scenario in the form of video for your reference and ensured the attached the sample.
Screenshot:
Screenshot:
|
|
Video link: https://www.syncfusion.com/downloads/support/directtrac/general/ze/RemoveFileRequest-852755400
Could you please let us know what you mean by the difference between these two requests? Please elaborate on query and if possible try to replicate the issue in the attached sample with replication procedure.
Regards,
Jeyanth.
SS
Stephan Schrade
August 5, 2020 08:32 PM UTC
Hi support,
as I wrote before, the problem only occurs when you try to delete a file which was just uploaded (without refreshing the page).
Please see the attached video.
In the first step I remove an already uploaded file which works perfect.
Then I upload another file and try to remove it immediately. But this generates another request as you can see in the right window.
Regards,
Stephan
Attachment: Syncfusion_Uploader_Problem.mov_ca6b8287.zip
JM
Jeyanth Muthu Pratheeban Sankara Subramanian
Syncfusion Team
August 6, 2020 02:58 PM UTC
Hi Stephan,
Thanks for your update.
We have validated your query. We suggest you to set args.PostrawFile as false in the removing event to restrict the raw file sent to the server. Please refer the below UG documentation for more details.
Thanks for your update.
We have validated your query. We suggest you to set args.PostrawFile as false in the removing event to restrict the raw file sent to the server. Please refer the below UG documentation for more details.
|
function onFileRemove(args) {
args.postRawFile = false;
args.customFormData = [{' Yii::$app->request->csrfParam; ?>' : ' Yii::$app->request->csrfToken; ?>'}];
}
|
Marked as answer
SS
Stephan Schrade
August 6, 2020 09:27 PM UTC
Hi support,
thank you very much.
This works for me now.
Regards,
Stephan
JM
Jeyanth Muthu Pratheeban Sankara Subramanian
Syncfusion Team
August 7, 2020 07:16 AM UTC
Hi Stephan,
Good day to you.
We are glad to hear that your issue has been resolved. Please let us know if you need any further assist on this.
Regards,
Jeyanth.
Good day to you.
We are glad to hear that your issue has been resolved. Please let us know if you need any further assist on this.
Regards,
Jeyanth.
SIGN IN To post a reply.
- 7 Replies
- 2 Participants
- Marked answer
-
SS Stephan Schrade
- Aug 1, 2020 10:09 PM UTC
- Aug 7, 2020 07:16 AM UTC