izozzy
Posts: 0
Joined: Sun Sep 14, 2014 1:37 pm

Return filename after upload

I ma using the javascript in the file upload tutorial and that works well. My images are uploaded properly to the database in the Files collection.

My question is, after uploading the image, how do i return the stored filename. I need this as I want to use in a field in another collection.

For something like this, should I be using the javascript to upload the file?

Can you help?

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Return filename after upload

Hello Izozzy,

files_upload_service returns in response the name of the saved file in the form
code
{
"filename":<serverFileName>,
"fileurl":<url>
}
/code
You can get it on the success of the event service.

izozzy
Posts: 0
Joined: Sun Sep 14, 2014 1:37 pm

Return filename after upload

I tried to put this javascript on the success of the event service,

alert(filename);

but it does not seem to work...

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Return filename after upload

Hello!

Change your code to prealert(data&#46;filename);/pre data is an object which contains entire service response.

izozzy
Posts: 0
Joined: Sun Sep 14, 2014 1:37 pm

Return filename after upload

I have just done what you have instructed, the alert window displays 'undefined' even though the file has successfully uploaded

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Return filename after upload

I am sorry for misunderstanding. Service response has the following structure
Image
so you need to use the following code prealert(data[0]&#46;success&#46;filename);/pre

izozzy
Posts: 0
Joined: Sun Sep 14, 2014 1:37 pm

Return filename after upload

thanks!

Nisa Khalid
Posts: 0
Joined: Tue May 05, 2015 1:36 pm

Return filename after upload

hello izozzy,
how did you put file name to another collection?

Return to “Issues”