View: 2627|Reply: 8
|
Mcm mana nk paparkan gambar yang kita dh upload
[Copy link]
|
|
korang... blh x tlg, mcm mana nk paparkan gambar yang kita dh upload.. pastu boleh delete. |
|
|
|
|
|
|
|
kau hanya perlu tambah function preview after upload la. then delete.
kalau tak mahu masuk dalam db rasanya kau kene try main dengan memory stream atau temperory table. |
|
|
|
|
|
|
|
Reply 2# kmkd
mcm mana tu eh.. masih xphm ag.. |
|
|
|
|
|
|
|
nak upload ke mana ni bang? image hosting? website? facebook? |
|
|
|
|
|
|
|
Reply 4# aziz79
image hosting... Sebab buat projek tuk web hosting nie.. blh upload, tp nk paparkan ja ada masalah.. |
|
|
|
|
|
|
|
tapi kau tak mahu save kan? so macam mana kau upload? |
|
|
|
|
|
|
|
Reply 6# kmkd
kena save juga'n kalau nk paparkan gmbar yang kita upload tu? btl x? sebb aq dh buat upload pastu blh papar. Tp bila aq cuba dua tiga kali, xmenjadi plak.. xtau ape yang xkene ag.. nie aq bagi koding yang aq buat aq guna dreamweaver cs4
- <?php
- include "conn_webHosting.php";
- $fileName = $_FILES['upload1']['name']; //get the file name
- $fileSize = $_FILES['upload1']['size']; //get the size
- $fileError = $_FILES['upload1']['error']; //get the error when upload
- if($fileSize > 0 || $fileError == 0){ //check if the file is corrupt or error
- $move = move_uploaded_file($_FILES['upload1']['tmp_name'], 'C:/Program Files/xampp/htdocs/Sistem web host pengiklanan/Halaman Utama/pengurus_muatnaik/'.$fileName); //save image to the folder
- if($move){
- echo "<h3></h3>";
- $q = "INSERT into pengurus_image VALUES('','$fileName','muatnaikIklan/$fileName')"; //insert image property to database
- $result = mysql_query($q);
- $q1 = "SELECT lokasi from pengurus_image where namaGambar = '$fileName' limit 1 "; //get the image that have been uploaded
- $result = mysql_query($q1);
- while ($data = mysql_fetch_array($result)) {
- $loc = $data['lokasi']; ?>
- <br/>
- <h2> </h2>
- <li><img src="<?php echo $loc; ?>" /> </li><!-- show the image using img src -->
- <?php
- }
- } else{
- echo "<h3></h3>";
- }
- } else {
- echo "".$fileError;
- }
- ?>
Copy the Code |
|
|
|
|
|
|
|
so kalau tak jadi tu sebab apa? gambar tak keluar atau apa?
kalau gambar tak keluar, adakah gambar tak save (broken link) atau benda lain? |
|
|
|
|
|
|
|
Reply 8# kmkd
dapt dh bro caranya.. aq guna coding nie ja.. untuk paparkan gmbar yg dh di upload..
- <?php
- $files = glob("images/*.*");
- for ($i=0; $i<count($files); $i++)
- {
- $num = $files[$i];
- print $num."<br />";
- echo '<img src="'.$num.'" alt="random image" />'."<br /><br />";
- }
- ?>
Copy the Code |
|
|
|
|
|
|
| |
|