Advertisement
Guest User

x

a guest
Jan 21st, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. <?php
  2. error_reporting(E_ALL);
  3. ini_set('display_errors', 1);
  4. if(isset($_GET['id'])) {
  5. include "inc/db.inc.php";
  6. if(isset($_FILES['fileToUpload'])){
  7. $errors= array();
  8. $file1 = $_FILES['fileToUpload']['name'];
  9. $file2 = $_FILES['fileToUpload2']['name'];
  10. $file3 = $_FILES['fileToUpload3']['name'];
  11. for($i=1;$i<=3;$i++) {
  12. $file_name = $_FILES['fileToUpload'.$i]['name'];
  13. $file_size =$_FILES['fileToUpload'.$i]['size'];
  14. $file_tmp =$_FILES['fileToUpload'.$i]['tmp_name'];
  15. $file_type=$_FILES['fileToUpload'.$i]['type'];
  16. $file_ext=strtolower(end(explode('.',$_FILES['fileToUpload'.$i]['name'])));
  17.  
  18. $expensions= array("jpeg","jpg","png");
  19.  
  20. if(in_array($file_ext,$expensions)=== false){
  21. header("location: edit_product.php?msg=notimage");
  22. }
  23.  
  24. if($file_size > 2097152){
  25. header("location: edit_product.php?msg=toolarge");
  26. }
  27.  
  28. if(empty($_FILES['fileToUpload'.$i])) {
  29. header("location: upimage.php?msg=emptyfile");
  30. }
  31. }
  32. if(empty($errors)==true){
  33. for($i=1;$i<=3;$i++) {
  34. move_uploaded_file($file_tmp,"../images/".$file_name);
  35. }
  36. $id = $_GET['id'];
  37. $sql = "UPDATE productslider SET img_product = '$file1', img_product2 = '$file2', img_product3 = '$file3' WHERE idProduct = '$id'";
  38. $query = mysqli_query($conn, $sql);
  39. if($query) {
  40. header("location: upimage.php?msg=success");
  41. } else {
  42. header("location: upimage.php?msg=error");
  43. }
  44. }
  45. }
  46. }
  47. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement