php - jQuery View Uploaded File -
i trying upload file view file on iframe not working.
here have tried
jquery('.file_upload1').change(function(){ jquery('iframe').attr('src', jquery(this).val()); $('iframe').attr('src', $('iframe').attr('src')); }); <label><input class="file_upload1" name="file_cover" type="file"></label> <div> <iframe src=""></iframe> </div>
if not work, can move uploaded file server directory path becomes valid? how this?
apart other problems , limitations of such solution, , answering "why not work?" question:
the
change
event needs nested inready
function:jquery("document").ready(function() { jquery('.file_upload1').change(function() { jquery('iframe').attr('src', jquery(this).val()); }); });
- the
src
attribute ofiframe
must a valid non-empty url potentially surrounded spaces. when selecting fileinput type file
, in windows valuec:\fakepath\file name goes.here
, before usingiframe
source, have rework little bit.
regarding
i'm trying upload file , display on iframe forcing reload
you don't need force reload achieve this. "upload" means page reloaded (well, unless upload handled using ajax, it's not case here guess). in order upload file, form must submitted , page needs reloaded. once reloaded, can construct full path of file , use in iframe
, like:
<iframe src="<?php echo $file_full_url; ?>"></iframe>
but if want preview file in iframe
before uploading server - won't possible due security reasons. see question reference: how full path of selected file on change of <input type=‘file’> using javascript, jquery-ajax?
Comments
Post a Comment