You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.2 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. <?php
  2. session_start();
  3. #error_log("Here is upload.php");
  4. file_put_contents("/tmp/log.txt", "uploadder\n", FILE_APPEND | LOCK_EX);
  5. function xvar_dump ($x) {
  6. ob_start();
  7. var_dump($x);
  8. return ob_get_clean();
  9. }
  10. $jo = array();
  11. foreach ($_FILES as $key=>$files){
  12. for ($i=0; $i < count($files['name']); $i++){
  13. $tmpname = $files['tmp_name'][$i];
  14. $ft = mime_content_type($tmpname);
  15. if ($ft != "application/pdf"){
  16. $jo = array(
  17. "type" => "error"
  18. );
  19. } else {
  20. $jo ["file-$key-$i"] = array(
  21. "url" => "url.txt",
  22. "name" => $files['name'][$i],
  23. "id" => $tmpname,
  24. "size" => sprintf("%0.1fK",$files['size'][$i]/1024.0)
  25. );
  26. file_put_contents("/tmp/log.txt", "file-$key-$i\n", FILE_APPEND | LOCK_EX);
  27. file_put_contents("/tmp/log.txt", $files['name'][$i], FILE_APPEND | LOCK_EX);
  28. }
  29. $_SESSION['files'][$tmpname]['content']=file_get_contents($tmpname);
  30. $_SESSION['files'][$tmpname]['row']=$_GET['row'];
  31. }
  32. }
  33. $files = "";
  34. foreach ($_SESSION['files'] as $key => $val) {
  35. $files .= "$key\n";
  36. }
  37. $j = json_encode ($jo);
  38. echo $j;
  39. file_put_contents("/tmp/log.txt", $j, FILE_APPEND | LOCK_EX);
  40. #error_log("\n\n ----- files ----- \n\n$files\n\n\n");
  41. #$xp = xvar_dump($_FILES);
  42. #error_log("\n\n ----- FILES ----- \n\n$$xp\n\n\n");