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:

  1. the change event needs nested in ready function:

    jquery("document").ready(function() {     jquery('.file_upload1').change(function() {         jquery('iframe').attr('src', jquery(this).val());     }); }); 
  2. the src attribute of iframe must a valid non-empty url potentially surrounded spaces. when selecting file input type file, in windows value c:\fakepath\file name goes.here, before using iframe 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

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -