How to rename an uploaded file with her original filename ?

Author Message

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

Sébastien Antoniotti

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 !

eZ Publish Freelance
web : http://www.webaxis.fr

Claudia Kosny

Tuesday 26 December 2006 2:04:06 am

Hi Sebastien

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>

Claudia

Sébastien Antoniotti

Tuesday 26 December 2006 5:23:42 am

It works very well !

Thanks a lot for this helpful feature !!

eZ Publish Freelance
web : http://www.webaxis.fr

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 19 2025 03:35:06
Script start
Timing: Jan 19 2025 03:35:06
Module start 'layout'
Timing: Jan 19 2025 03:35:06
Module start 'content'
Timing: Jan 19 2025 03:35:07
Module end 'content'
Timing: Jan 19 2025 03:35:07
Script end

Main resources:

Total runtime0.8684 sec
Peak memory usage4,096.0000 KB
Database Queries63

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0059 589.4141152.6563
Module start 'layout' 0.00590.0033 742.070339.5078
Module start 'content' 0.00920.8574 781.5781557.9141
Module end 'content' 0.86660.0017 1,339.492212.0938
Script end 0.8683  1,351.5859 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00370.4300160.0002
Check MTime0.00180.2039160.0001
Mysql Total
Database connection0.00070.083510.0007
Mysqli_queries0.814193.7487630.0129
Looping result0.00050.0627610.0000
Template Total0.831495.720.4157
Template load0.00250.288620.0013
Template processing0.828995.450720.4144
Template load and register function0.00010.011110.0001
states
state_id_array0.00120.139210.0012
state_identifier_array0.00120.139420.0006
Override
Cache load0.00180.2125280.0001
Sytem overhead
Fetch class attribute can translate value0.00060.068720.0003
Fetch class attribute name0.00100.115660.0002
XML
Image XML parsing0.00070.081420.0004
class_abstraction
Instantiating content class attribute0.00000.002180.0000
General
dbfile0.00080.0912160.0000
String conversion0.00000.001240.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
7content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 19
 Number of unique templates used: 6

Time used to render debug report: 0.0002 secs