- Posts: 3
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Present previously uploaded image in subsequent question
- ybanens
- Topic Author
- Offline
- New Member
Less
More
5 years 10 months ago #169217
by ybanens
Present previously uploaded image in subsequent question was created by ybanens
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.
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
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.
Code:
[{ "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
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10630
- Thank you received: 3696
5 years 10 months ago #169228
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on 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:
Sample survey attached:
Regarding the second part, you cannot access data from a previous survey.
So, if the upload question code is "upload1" and only one upload is allowed, you could use an <img /> tag like this:
Code:
<img src="../upload/surveys/{SID}/files/{stristr(str_replace('filename":"', '', stristr(upload1, 'filename":"')), '"', 'true')}" />
Sample survey attached:
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: ybanens
The topic has been locked.
- ybanens
- Topic Author
- Offline
- New Member
Less
More
- Posts: 3
- Thank you received: 0
5 years 9 months ago - 5 years 9 months ago #169363
by ybanens
Replied by ybanens on 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:
Becomes this:
(Note: My upload question is called FILEUPLOAD)
Do you have any insights into what may be going wrong?
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:
Code:
<img src="../upload/surveys/{SID}/files/{stristr(str_replace('filename":"', '', stristr(FILEUPLOAD, 'filename":"')), '"', 'true')}" />
Code:
<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: 5 years 9 months ago by ybanens.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10630
- Thank you received: 3696
5 years 9 months ago #169378
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on 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.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10630
- Thank you received: 3696
5 years 9 months ago #169379
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on 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.
The topic has been locked.
- ybanens
- Topic Author
- Offline
- New Member
Less
More
- Posts: 3
- Thank you received: 0
5 years 9 months ago #169386
by ybanens
Replied by ybanens on 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.
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.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10630
- Thank you received: 3696
5 years 9 months ago #169387
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Present previously uploaded image in subsequent question
Open your personal settings and switch the HTML editor mode.Pardon my ignorance, but I don't see where to change out of the HTML editor!
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
The topic has been locked.