Forums / Setup & design / How to rename an uploaded file with her original filename ?

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

eZ debug

Timing: Jan 20 2025 17:27:28
Script start
Timing: Jan 20 2025 17:27:28
Module start 'content'
Timing: Jan 20 2025 17:27:29
Module end 'content'
Timing: Jan 20 2025 17:27:29
Script end

Main resources:

Total runtime1.2156 sec
Peak memory usage4,096.0000 KB
Database Queries200

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0053 587.9688180.7969
Module start 'content' 0.00531.0914 768.7656585.4219
Module end 'content' 1.09670.1188 1,354.1875337.3359
Script end 1.2155  1,691.5234 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00350.2917210.0002
Check MTime0.00130.1103210.0001
Mysql Total
Database connection0.00060.050010.0006
Mysqli_queries1.140593.82652000.0057
Looping result0.00180.14861980.0000
Template Total1.187397.720.5936
Template load0.00190.152620.0009
Template processing1.185497.520220.5927
Template load and register function0.00010.006810.0001
states
state_id_array0.00090.071410.0009
state_identifier_array0.00110.093820.0006
Override
Cache load0.00160.1295280.0001
Sytem overhead
Fetch class attribute can translate value0.00130.107530.0004
Fetch class attribute name0.00100.078360.0002
XML
Image XML parsing0.00080.069330.0003
class_abstraction
Instantiating content class attribute0.00000.001580.0000
General
dbfile0.00790.6515270.0003
String conversion0.00000.001830.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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