Jump to content
php.lv forumi
  • 0

file upload preview


renathy

Question

Man formaa ir file upload:

 

<input name="upload" id="upload" type="file" value="Select Image">

 

Vajaga, lai pirms faila Submitoshanas varetu uztaisit Preview. Vai to var ar Javascript?

 

 

Sliktaka gadijuma, ja nevar ta, lai automatiski - varbut var ar pogu "Preview".

Ka tad iegut bildes src, lai to paraditu?

Edited by renathy
Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0

Izmantojot js to var izdarīt, bet tas nav elementāri. Vajadzēs submit'ot formu uz iframe'u, tad sagaidīt atbildi, kur būs links uz augšupielādēto bildi un tad darīt ko nu tev vajag.

 

Vēl vari izmantot jaunās HTML5 fīčas, bet pagaidām, jau tas nebūtu īpaši gudri - https://developer.mozilla.org/en/Using_files_from_web_applications

 

Un, protams, vari darīt kā briedis saka.

Link to comment
Share on other sites

  • 0

IE briivi atljauj panjemt bildi o Usera kompja un too attelot, parejiem brauzeriem buus problematiskak

Idejiski tas buutu taa...

<script>
function paradiit()
{

 var celjsh= document.getElementById('bildes_inputc').value;
   var bildiite='<img src="file://'+celjsh+'">';
 document.getElementById('bilde').innerHTML=bildiite;
return false;
}
</script>
<input type="file" id="bildes_inputc">
<div id="bilde">
</div>
<br><a href="Javascript:void(0)" onclick="paradiit(); return false;">Paskatiit</a>

kautkaa taa, kodu neparbaudiju, un sintaksi arii .. bet nu doma ir saada:

<kad useris ievada bildi tad input laukaa ar tipu FIle tiek ierakstiits bildes(faila) atrasanas vieta uz usera kompja.

Too iegustam ar standarta GetElementByDI.value

talak ieguto vertiibu ievietojam HTML fragmenta, kuru savukart iesprauzjam vietaa hur vajadzes izvadiit ( teiksim DIV elementaa )

--

Kaa jau mineju IE vajadzetu stradat, par parejiem brauzeriem nezinu , varbuut jaa, varbuut nee..

Patestee pats..

Edited by Grey_Wolf
Link to comment
Share on other sites

  • 0

Grey_Wolf: tadu variantu jau megjinaju, tiesham nestrada, jo nepadod folderi, bet tikai file nosaukumu.

 

Ar to flashu gan laikam nekas shobrid nesanaks, jo:

 

lapu taisu uz phpbb3 bazes - esoshaja admin paneli pievienojot jaunus moduljus,

bez tam ne reizi muzhaa neesmu rakstisju neko flashaa, un shobrid izskata, ka galigi nav laika to apgut.

 

R.

Link to comment
Share on other sites

  • 0

Atkartoshos... Un tomer japacenshas Postu izlasiit visu, nevis tikai paris teikumus...

IE briivi atljauj panjemt bildi o Usera kompja un too attelot, parejiem brauzeriem buus problematiskak

..

Kaa jau mineju IE vajadzetu stradat, par parejiem brauzeriem nezinu , varbuut jaa, varbuut nee..

IE vismz liidz 7 versijai Padod Pilnu celju liidz bildei ..

Un idejiski arii FF/Operai tam celjam kautkur buutu jaglabajas..

Zinu ka FF papildus savac arii faila izmeru ...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...