Advertisement
GWibisono

Upload super sangat sederhana

Apr 15th, 2012
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.93 KB | None | 0 0
  1. <?php
  2. /*
  3. SANGAT BUTUH FOLDER TMP
  4.  
  5. */
  6. if($_FILES) {
  7.     $t=mktime();
  8.     foreach($_FILES[my] as $nm=>$v) $$nm=$v;
  9.    
  10.     copy($_FILES[my][tmp_name], 'tmp/'.$t.".tmp");
  11.     $f=file_get_contents('t.txt'); $f.="\n$t\t$name\t$type\t$size";
  12.     $handle = fopen('t.txt', "w");
  13.     fwrite($handle, $f);
  14.     fclose($handle);
  15.  
  16. }
  17.  
  18. $f=file_get_contents('t.txt');
  19. $a=explode("\n",$f);
  20. if($_GET[a]=='down')
  21. {
  22.     foreach($a as $v)
  23.     {
  24.         $a2=explode("\t",$v);
  25.         if($a2[0]==$_GET[id])
  26.         {
  27.             header('Content-type:'.$a2[2]);
  28.             header('Content-Disposition: attachment; filename="'.$a2[1].'"');
  29.             $f2=file_get_contents('tmp/'.$a2[0].'.tmp');
  30.             die($f2);
  31.  
  32.         }
  33.  
  34.     }
  35.  
  36. }
  37.  
  38. $s=count($a)."<ol>";
  39. foreach($a as $v)
  40. {
  41.     $a2=explode("\t",$v);
  42.     $s.="<li><a href='?a=down&id=$a2[0]'>$a2[1]</a> ($a2[2])";
  43. }
  44. $s.="</ol>";
  45.  
  46. ?>
  47. <form enctype='multipart/form-data' method='post'>
  48. <input type=file name='my' />
  49. <input type=submit> </form> <? echo $s;
  50. //phpinfo();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement