- Posts: 115
- Thank you received: 4
Ask the community, share ideas, and connect with other LimeSurvey users!
function displayUploadedImage(results, imgNumber) { if($.isArray(results)) { // Only if there is an upload result var resultsArr = new Array(); resultsArr = results; var imgArr = resultsArr[imgNumber-1]; if(imgArr) { // Only if this image number exists var imgExtLC = imgArr['ext'].toLowerCase(); if(imgExtLC == 'gif' || imgExtLC == 'png' || imgExtLC == 'jpg' || imgExtLC == 'jpeg' || imgExtLC == 'tif' || imgExtLC == 'tiff' || imgExtLC == 'bmp') { // Only the file is an image var surveyRoot = location.pathname.split('index.php')[0]; var fieldNames = $( 'input#fieldnames' ).attr('value'); var tmp = fieldNames.split('X'); var sID = tmp[0]; var imgFilename = imgArr['filename']; document.write('<img src="'+surveyRoot+'index.php/uploader/index/sid/'+sID+'/filegetcontents/'+imgFilename+'" class="pipedImage" />'); } else { displayImageError(); } } else { displayImageError(); } } } function displayImageError() { document.write('<span style="color:red">No image found</span>'); }
<script type="text/javascript" charset="utf-8"> displayUploadedImage({uploadQuestionCode}, 1); </script>
Correct, the file is (sort of) encrypted when stored.What you can't do is "somehow" append the file extension onto the converted file once uploaded.
Not with JavaScript. It may be possible by hacking the core code but would introduce some security issues - the files would be accessible to everyone.Is there a way to "branch" the question upload function such that two images are stored?
<script type="text/javascript" charset="utf-8">displayUploadedImage({q99.shown});</script>
function displayUploadedImage(results) { if($.isArray(results)) { $.each(results, function(i, result) { var ext = result['ext'].toLowerCase(); if(ext == 'gif' || ext == 'png' || ext == 'jpg' || ext == 'jpeg') { var surveyRoot = location.pathname.split('index.php')[0]; var fieldNames = $( 'input#fieldnames' ).attr('value'); var tmp = fieldNames.split('X'); var sID = tmp[0]; var imgFilename = result['filename']; document.write('<img src="'+surveyRoot+'index.php/uploader/index/sid/'+sID+'/filegetcontents/'+imgFilename+'" style="max-width:100%" />'); } }); } }
Uncaught syntax error: Unexpected token >
<table class="question-wrapper"> <tr> <td class="questiontext"> <div class="qt_background"> <span class="asterisk"></span><span class="qnumcode"> </span><p> Where is the image?<br /> <script type="text/javascript" charset="utf-8">displayUploadedImage(<span style='background-color: #eee8aa;'><span title='Undefined variable' style='border-style: solid; border-width: 2px; border-color: red;'><span title='Undefined variable' style='color: red; font-weight: bold'>q1403.shown</span></span></span>);</script></p>
Failed to load resource: the server responded with a status of 404 (Not Found) https://www.springboltconsulting.com/survey/index.php/uploader/index/sid/752182/filegetcontents/fu_3jjg2knf2tpe49t
<script type="text/javascript" charset="utf-8">displayUploadedImage([{ "title":"","size":"35.878","name":"Jenny.jpg","filename":"fu_3jjg2knf2tpe49t","ext":"jpg" }]);</script> <span style="color:red">No image found</span>