Present previously uploaded image in subsequent question

More
3 weeks 4 days ago #169217 by ybanens
ybanens created the topic: Present previously uploaded image in subsequent question
Hi folks,

I have a client who would like to allow respondents to upload an image of themselves, then present them with a modified (aged) version of that image in a subsequent survey.

Is there a way to use Expression Manager to generate the URL for a stored image, based on a participant's token?

First, I'd like to part-prove the concept by letting a participant upload an image, then showing it back to them in a subsequent question. I tried creating one question with the code FILEUPLOAD, then populating the question text of a second question with {FILEUPLOAD}, but it returned only the metadata about the image, i.e.
[{ "title":"","comment":"","size":"141.447","name":"unityLogo.png","filename":"fu_3xtte3n3g8fhcxg","ext":"png" }]

Can anybody help me with either the first part of the question (show an image back to someone after they've uploaded it) or the whole problem (show an image to someone in a different survey, that they uploaded in another)?

Thanks very much

Please Log in or Create an account to join the conversation.

More
3 weeks 3 days ago #169228 by tpartner
tpartner replied the topic: Present previously uploaded image in subsequent question
Regarding the first part - have a look at this post about how to parse the returned Expression Manager value - www.limesurvey.org/forum/can-i-do-this-w...uploaded-file#122453 .

So, if the upload question code is "upload1" and only one upload is allowed, you could use an <img /> tag like this:

<img src="../upload/surveys/{SID}/files/{stristr(str_replace('filename":"', '', stristr(upload1, 'filename":"')), '"', 'true')}" />

Sample survey attached:

File Attachment:

File Name: limesurvey...4455.lss
File Size:14 KB



Regarding the second part, you cannot access data from a previous survey.

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
The following user(s) said Thank You: LouisGac, ybanens

Please Log in or Create an account to join the conversation.

More
3 weeks 1 day ago - 3 weeks 1 day ago #169363 by ybanens
ybanens replied the topic: Present previously uploaded image in subsequent question
Thanks very much tpartner.

The code doesn't seem to parse correctly for me when it's embedded in an IMG tag. I can successfully pull the attributes of the file using the example snippets you provided, but it stops working once it's in the IMG tag.

You can see in the code colouring in the attached screenshot that the parser stops treating it as a string after the second double-quotes and it doesn't start again on the third one.

When the question is saved and closed, the code gets mangled and saved in the wrong order, as follows :-
This:
<img src="../upload/surveys/{SID}/files/{stristr(str_replace('filename":"', '', stristr(FILEUPLOAD, 'filename":"')), '"', 'true')}" />
Becomes this:
<img :="" src="../upload/surveys/{SID}/files/{stristr(str_replace('filename" />

(Note: My upload question is called FILEUPLOAD)

Do you have any insights into what may be going wrong?
Attachments:
Last Edit: 3 weeks 1 day ago by ybanens.

Please Log in or Create an account to join the conversation.

More
3 weeks 1 day ago #169378 by tpartner
tpartner replied the topic: Present previously uploaded image in subsequent question
Try without using the HTML editor.

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in or Create an account to join the conversation.

More
3 weeks 1 day ago #169379 by tpartner
tpartner replied the topic: Present previously uploaded image in subsequent question
BTW, did my sample survey work when imported without modification?

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in or Create an account to join the conversation.

More
3 weeks 22 hours ago #169386 by ybanens
ybanens replied the topic: Present previously uploaded image in subsequent question
I'm in a managed environment and don't have the ability to import LSS files. I did try opening the file with a text editor and grabbing the code out of there, with the same result.

Pardon my ignorance, but I don't see where to change out of the HTML editor! You don't just mean switching to source? There may be some settings hidden from me in this environment.

Please Log in or Create an account to join the conversation.

More
3 weeks 21 hours ago #169387 by tpartner
tpartner replied the topic: Present previously uploaded image in subsequent question

Pardon my ignorance, but I don't see where to change out of the HTML editor!

Open your personal settings and switch the HTML editor mode.


Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!