Forums / Setup & design / How to rename an uploaded file with her original filename ?
Sébastien Antoniotti
Friday 22 December 2006 6:21:06 am
Hi everybody,
When we upload a file (via the file attribute of a class), she's renamed before her storage with a name like this : f69e87e24c50770d4e7e6f52875b582c.mp3
So I want to rename this file with her orignal filename before display it with an html link.
Can someone help me ?
eZ Publish Freelance web : http://www.webaxis.fr
Claudia Kosny
Saturday 23 December 2006 7:04:36 am
Hi Sebastien
Are you sure that you need to do this? At least on EZ 3.8.3 the file is stored in the var directory under a name like you mentioned, but it I use the default template for displaying a link to this file, I get a link to /content/download/<object_id>/<attribute_id>/file/original_filename.mp3
So if you have a look at the template design/base/override/templates/datatype/ezbinaryfile.tpl, you can see how they create a link with the original filename.
Claudia
Tuesday 26 December 2006 12:13:58 am
Hi Claudia,
The problem is that I cant display the link using attribute_view_gui because, I need to custom the link :
<a title="Télécharger {attribute_view_gui attribute=$p.data_map.titre} - (clic droit, puis Enregistrer la cible sous)" href="{$p.data_map.son.content.filepath|ezroot('no')}" style="margin-right:3px;width:30px;height:30px;float:right;display:block;"></a>
Thanks for your help !
Tuesday 26 December 2006 2:04:06 am
Just have a look at the template for ezbinary, there you can see how to create a link for downloading a binary file. The result should look roughly like this (not tested at all):
<a title="Télécharger {attribute_view_gui attribute=$p.data_map.titre} - (clic droit, puis Enregistrer la cible sous)" href={concat("content/download/",$p.data_map.son.contentobject_id,"/",$p.data_map.son.id,"/file/",$p.data_map.son.content.original_filename)|ezurl} style="margin-right:3px;width:30px;height:30px;float:right;display:block;"> {$p.data_map.son.content.original_filename|wash(xhtml)}</a>
Tuesday 26 December 2006 5:23:42 am
It works very well !
Thanks a lot for this helpful feature !!