Yet another PHP based Funko Pop collection tracker, about as bare bones as you can get, but it's functional.
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 

75 linhas
3.3 KiB

  1. <?php
  2. $pagetitle = "Image Uploader";
  3. include_once ('header.php');
  4. include_once ('smart_resize_image.function.php');
  5. $uploadedimage = mysqli_real_escape_string($con, $_POST['uploadyn']);
  6. $funkoid = mysqli_real_escape_string($con, $_POST['funkoid']);
  7. $imageid = $_SESSION['imageid'];
  8. $uploadyn = $_SESSION['image'];
  9. $remimage = $_SESSION['imagepath'];
  10. #
  11. # File name should be a combo of the time (so no 2 images are named the same),
  12. # pop number, pop name, and username of uploader.
  13. # For example: 1497650696_147_C2-B5_funkybeast808.jpg
  14. #
  15. if (isset($_SESSION['userid'])){
  16. if ($uploadedimage == "default") {
  17. extract($_POST);
  18. $UploadedFileName = $_FILES['uploadedfile']['name'];
  19. $extension = end(explode(".", $UploadedFileName));
  20. if($UploadedFileName != '') {
  21. $upload_directory = "images/"; //This is the folder which you created just now
  22. $TargetPath=time()."_".$_SESSION['popno']."_".$_SESSION['popname']."_".$uname.".".$extension;
  23. if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $upload_directory.$TargetPath)) {
  24. $resized = $upload_directory.$TargetPath;
  25. smart_resize_image ($upload_directory.$TargetPath, null, 230, 300, true, $resized, false, false, 100);
  26. $insertfile = "INSERT INTO funkopops.popimages (funkoid, userid, imagepath) VALUES ($funkoid, $userid, '$TargetPath')";
  27. if (!$addpath = $con->query($insertfile)) {
  28. die ('There was an error running the query: [' . $con->error . ']');
  29. }
  30. }
  31. }
  32. echo 'You have successfully uploaded a new image.<BR />';
  33. echo 'Redirecting back to editor.<BR />';
  34. header("refresh:2;url=edit.php?id=$funkoid");
  35. include_once ('footer.php');
  36. exit();
  37. } else if ($uploadedimage == "existing") {
  38. extract($_POST);
  39. $UploadedFileName = $_FILES['uploadedfile']['name'];
  40. $extension = end(explode(".", $UploadedFileName));
  41. if($UploadedFileName != '') {
  42. $upload_directory = "images/"; //This is the folder which you created just now
  43. $TargetPath=time()."_".$_SESSION['popno']."_".$_SESSION['popname']."_".$uname.".".$extension;
  44. if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $upload_directory.$TargetPath)) {
  45. $resized = $upload_directory.$TargetPath;
  46. smart_resize_image ($upload_directory.$TargetPath, null, 250, 0, true, $resized, false, false, 100);
  47. $insertfile = "UPDATE funkopops.popimages SET imagepath = ('$TargetPath') WHERE imageid = $imageid AND funkoid = $funkoid AND userid = $userid";
  48. if (!$addpath = $con->query($insertfile)) {
  49. die ('There was an error running the query: [' . $con->error . ']');
  50. }
  51. }
  52. }
  53. if (file_exists("images/$remimage")) {
  54. unlink("images/$remimage");
  55. } else {
  56. echo 'Image ' . $remimage . ' was NOT deleted.<BR />';
  57. }
  58. echo 'You have successfully updated the image.<BR />';
  59. echo 'Redirecting back to editor.<BR />';
  60. header("refresh:2;url=edit.php?id=$funkoid");
  61. include_once ('footer.php');
  62. exit();
  63. } else {
  64. $fid = $funkoid;
  65. echo '<form action="imageupload.php" method="post" enctype="multipart/form-data">';
  66. echo 'Filename: <input type="hidden" name="funkoid" value="' . $fid . '">';
  67. echo '<input type="hidden" name="uploadyn" value="' . $uploadyn . '">';
  68. echo '<input type="file" name="uploadedfile"><br>';
  69. echo '<input type="submit" value="Upload image"></form>';
  70. }
  71. } else {
  72. echo 'Please login <A HREF="index.php" CLASS="navlink">HERE</A> before continuing.<BR />';
  73. }
  74. include_once ('footer.php');
  75. ?>