Search

I've been working on a project that requires that visitors be able to upload a single image when a comment is made on the Web site. I was thinking that creating a File Upload field (named 'yourpic') in Sections would be represented accordingly in the Component Event that I create to allow for the frontend manipulation. When I view the Event though it is not providing the example XSLT to be included in the Page for displaying and creating the functionality for image uploading.

I then attempted to add:

<label>
  <xsl:text>Upload Pic</xsl:text>
  <input name="fields[yourpic]" type="file" />
</label>

Thinking that once the form is submitted the file would be uploaded and placed in the folder defined in the File Upload field of Sections. The path to the file seems to be saved, but the upload of the image doesn't work, because it seems the path is not specified, so the non-existent image links to something like this: http://localhost:8888/test_project/workspace0034.jpg

Note how the image name merges with the workspace folder instead of being placed in the /workspace/uploads.

Any help would be appreciated!

I'm just guessing at what the problem might be here, but it sounds like your form might be missing the following:

  1. Does the form have an enctype="multipart/form-data" attribute?
  2. Is MAX_FILE_SIZE the first input inside the form?

Your XSLT should look something like this:

<form action="." method="post" enctype="multipart/form-data">
  <div>
    <input name="MAX_FILE_SIZE" type="hidden" value="5242880"/>
    <label>
      <xsl:text>Upload Pic</xsl:text>
      <input name="fields[yourpic]" type="file"/>
    </label>
  </div>
</form>

Very nice! Thanks so much, I made the changes and it works beautifully!

You're welcome. Great to hear.

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