how to edit an image from the front end,(am using file upload field in the back end) i have an event where am editing the form values,while editing if there is no image , it should retain the previous image stored how to achieve this ?

Just don't send the image field in the POST array and Symphony should retain it. If that fails, send the existing image path and filename as a string.

thanks nick, i tried both the methods but am not able to achieve anything any other tips ?

None, I'm fresh out of tips I'm afraid.

   <input name="fields[picture]" type="file" id="user-picture" />
               <input type="hidden" value="{$workspace}/user_pic/rotet.jpg" name="fields[picture]"/>

i followed this method "send the existing image path and filename as a string" the used above code it does not works

"send the existing image path and filename as a string" , how to do this ?

You might have to remove the type=file element from the DOM completely. To check, see what the HTML looks like in the Symphony backend when you submit an entry that already has an image. You want to emulate just that.

<input type="hidden" value="/user_pic/slide4.jpg" name="fields[user-picture]">

this is the symphony backend code,

i tried with this , but it does not seems to work

I tried with ignoring file value in the post array as nick said

Just don't send the image field in the POST array and Symphony should retain it

i checked for the image null in the front end and using php unsetachieved whatever i want

I’ve met the very same problem: I needed to edit a section containing a file upload field via front end. If you use the normal code snippet in the Example Front-end Form Markup provided by the event:

<label class="file">My Upload Field
    <input name="fields[my-upload-field]" type="file" />

and you’ve already uploaded a file and you only want to change all the data in the fields of the section but the one in the File Upload Field, submitting the edit event will make you loose the file already uploaded. If you submit a blank file upload input, it will erase it: in order to keep it you should re-insert the file via the file upload input, so either you’re a very tidy person and you know exactly where such a file is in your computer or you’re in trouble.

So I followed Nick Dunn’s suggestion: I’ve unashamedly copied the way the upload field works in the Symphony back end. Here there is the code snipped, so that if you stumbled upon the very same problem you can take advantage of it:

<xsl:template match="entry">

[here there is the first part of the form code]

<label class="file">My Upload Field
        <xsl:when test="my-upload-field/filename">
                <a href="{$workspace}/{my-upload-field/@path}/{my-upload-field/filename}">/workspace<xsl:value-of select="my-upload-field/@path"/>/<xsl:value-of select="my-upload-field/filename"/></a>
                <input name="fields[my-upload-field]" type="hidden" value="/{my-upload-field/@path}/{my-upload-field/filename}" />
            <input name="fields[my-upload-field]" type="file" />
    // Upload fields
    $('<em>' + 'Remove File' + '</em>').appendTo('label.file:has(a) span').click(function(event) {
        var span = $(this).parent(),
            name = span.find('input').attr('name');

        // Prevent clicktrough

        // Add new empty file input
        span.empty().append('<input name="' + name + '" type="file" />');

[here there is the rest of the form code]


You need jQuery in order for the code to work.

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