Search

A new extension, "Reflected file upload" is now available for download. Comments and feedback can be left here but if you discover any issues, please post it on the issue tracker.

I added an extension: The Reflected File Upload field

This extension is a variation of the 'Unique Upload Field' extension by Michael Eichelsdoerfer and the Reflection field by Rowan Lewis.

This field enables you to specify the naming expression using reflection:

{entry/field-1}-{entry/field-2}-{entry/@id}

When uniqueness is important you can enable the "Always create unique name" option. This will add "Unique Upload Field" behavior by appending a unique token to the filename.

[Installation]

  1. Upload the 'reflecteduploadfield' folder in this archive to your Symphony 'extensions' folder.

  2. Enable it by selecting the "Field: Reflected File Upload", choose Enable from the with-selected menu, then click Apply.

  3. You can now add the "Reflected File Upload" field to your sections.

Please report issues and stuff in the issue tracker!

Ah nice, so you could create 'friendly' filenames while ensuring they remain unique?

@davidhund Yes, Although the uniqueness is still a 13 character uniqid() appended to the file.

Another way to keep names unique is to use the entry id in the expression. This creates possible issues when there are 2 reflectedupload fields with the same expression in the same section... not that i can think of a situation where that might be needed.

Sure, so: what exactly is the use-case of this field? In other words, apart from the aesthetics, why would I need such a specific filename?

I had a case where website visitors could upload files that belonged to some kind of dossier.

To prevent a complete mess in the upload folder, i used this field to name the file as [dossier_reference]-[client]-[id]

It made it easier to find the correct files for a dossier and, since i am packaging those files so my client can download those files, they have a better chance of finding what they need.

Apart from that there could be SEO advantages (never trust a client to use sensible filenames).

And yes, aesthetics, a not to be underestimated advantage imho ;-)

why would I need such a specific filename?

From a Digital Asset Management point of view, this is a great idea. Storing files with thier original name isn't a useful way of doing things for DAM, ut having the filename unique and dynamic to the entry details is really useful for DAM.

Would it be difficult for you to add the ability to add the files to a folder with the name of the section, or a specified folder name?

@Zimmen - genius! Nice work!

@designermonkey that should be possible. The way a folder is specified in the default file upload field already makes it possible to choose a folder for a section, you just have to create it yourself first and then select it from the pulldown.

Creating a folder based on another field in an entry might be useful, like a category field, files get uploaded into that folder then.

@bzerangue thanks!

Fatal error: Cannot access private property Symphony::$Database in /home/ /extensions/reflecteduploadfield/extension.driver.php on line 43

Symphony 3.0 (Only occurs when use with subsection manager)

Seems to work if comment out that for loop

Thanks for great extension and further tips.

After installing this extension (Symphony 2.3.1), I get this error when trying to edit a section:

Fatal error: Call-time pass-by-reference has been removed in /Applications/MAMP/htdocs/housex/extensions/reflecteduploadfield/fields/field.reflectedupload.php on line 15

Call-Time pass by reference was deprecated in php5.3 and has been removed in php 5.4.

As you can see here $wrapper is passed by reference on call-time. This may be an accidentally mistake because there's absolutely no reason to do so. So, just remove the call-time reference and you should be good.

I have a problem with this extension on clean install Symphony 2.3.3 when uploading files from the back-end.

The files seem to be uploading fine, but as soon as the entry is saved, I get an error message: "The file uploaded is no longer available. Please check that it exists, and is readable."

The odd thing is that the file is actually uploaded and when I click on the link within the field it opens up nice. The error message seems to be a false positive.

Has anybody experienced something similar? Any ideas what the issue might be?

There has been a change in how Symphony handles file paths. The core Upload field and the Unique Upload Field extension are compatible with this.

To check if the Reflected File Upload is compatible, can you take a look into the database? Grab a field ID from sym_fields_reflectedupload (no matter which), then look into sym_entries_data_YOURFIELDID. There must be a file column. Do the values in that column contain the path or just the filename? If the path is included, this extension is not compatible. If it's just the filenames, your problem is probably elsewhere.

I took a look into the database, following your steps, michael-e. There is a file column and it does indeed contain the path, not only the filename. I figured out what to change in the extension: line 132 needs to be deleted:

$new_value = $rel_path . '/' . $new_value;

I have sent a pull request to TwistedInteractive's repository. It now works with Symphony CMS 2.3.3

After fixing the extension, you will need to update your database entries. Follow these steps:

  1. Look into the table sym_fields_reflectedupload which field ids are listed. These are the tables to edit.
  2. Open one by one the sym_entries_data_XX tables
  3. In each copy from the file field the path (e.g. /images/products/)
  4. Perform in each the SQL command UPDATE 'sym_entries_data_XX' SET file = REPLACE(file, '/images/products/', '') you will need to replace XX against the id you found out and the path against the one you copied.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details