Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Upload i lokalizacja pobranych plikow
JamalBIG
post
Post #1





Grupa: Zarejestrowani
Postów: 496
Pomógł: 1
Dołączył: 16.01.2008
Skąd: Świnoujście

Ostrzeżenie: (0%)
-----


Witam

Znalazłem w internecie fajny skrypt do uploadu ale mam problem bo niby plik się pobiera ale nie mam pojęcia gdzie?!
Przejrzałem skrypt i nie mogę się doszukać fragmentu zapisującego go w danej lokalizacji...

  1. <?php
  2. $ftmp = $_FILES['image']['tmp_name'];
  3. $oname = $_FILES['image']['name'];
  4. $fname = $_FILES['image']['name'];
  5. $fsize = $_FILES['image']['size'];
  6. $ftype = $_FILES['image']['type'];
  7.  
  8. if(IsSet($ftmp)) :
  9.    $fp      = fopen($ftmp, 'r');
  10.    $content = fread($fp, filesize($ftmp));
  11.    $content = addslashes($content);
  12.    fclose($fp);
  13.    // include your database configuration & connection
  14.    /*$new_file_name = time()."_".$fname;
  15.     $query = "INSERT INTO file_upload (name, type, size, content)
  16.     VALUES('".$new_file_name."', '".$ftype."', ".$fsize.", '".$content."')";
  17.     $result = mysql_query($query);
  18.     $file_id = mysql_insert_id();*/
  19. ?>
  20. <html><head><script>
  21. var par = window.parent.document;
  22. var list = par.getElementById('list');
  23. var fileid = par.createElement('div');
  24. var inpid = par.createElement('input');
  25. var imgdiv = list.getElementsByTagName('div')[<?=(int)$_POST['imgnum']?>];
  26. var image = imgdiv.getElementsByTagName('img')[0];
  27.  
  28. imgdiv.removeChild(image);
  29. list.removeChild(imgdiv);
  30.  
  31. fileid.setAttribute('id', 'upfile<?=$file_id?>');
  32. fileid.innerHTML = '<?=$oname?>';
  33. inpid.type = 'hidden';
  34. inpid.name = 'filename[]';
  35. inpid.value = '<?=$file_id?>';
  36. list.appendChild(fileid);
  37. fileid.appendChild(inpid);
  38. </script></head>
  39. </html>
  40. <?php
  41.    exit();
  42. endif;
  43. ?>
  44. <html><head>
  45. <script language="javascript">
  46. function upload(){
  47. // hide old iframe
  48.    var par = window.parent.document;
  49.    var num = par.getElementsByTagName('iframe').length - 1;
  50.    var iframe = par.getElementsByTagName('iframe')[num];
  51.    iframe.className = 'hidden';
  52.  
  53.    // create new iframe
  54.    var new_iframe = par.createElement('iframe');
  55.    new_iframe.src = 'upload.php';
  56.    new_iframe.frameBorder = '0';
  57.    par.getElementById('iframe').appendChild(new_iframe);
  58.  
  59.    // add image progress
  60.    var list = par.getElementById('list');
  61.    var new_div = par.createElement('div');
  62.    var new_img = par.createElement('img');
  63.    new_img.src = 'indicator.gif';
  64.    new_img.className = 'load';
  65.    new_div.appendChild(new_img);
  66.    list.appendChild(new_div);
  67.  
  68.    // send
  69.    var imgnum = list.getElementsByTagName('div').length - 1;
  70.    document.iform.imgnum.value = imgnum;
  71.    document.iform.submit();
  72. }
  73. </script>
  74. <style>
  75. body {vertical-align:top;}
  76. </style>
  77. <head>
  78. <body>
  79. <form name="iform" action="" method="post" enctype="multipart/form-data">
  80. <input id="file" type="file" name="image" onchange="upload()" />
  81. <input type="hidden" name="imgnum" />
  82. </form>
  83. </html>
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 1)
EarthCitizen
post
Post #2





Grupa: Zarejestrowani
Postów: 286
Pomógł: 70
Dołączył: 13.01.2009

Ostrzeżenie: (0%)
-----


To jest cały kod tego skryptu? Ja tam nie widzę poza $_FILES kodu potrzebnego do uploadu pliku przez php...
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 22.08.2025 - 00:04