Advertisement
Guest User

Untitled

a guest
May 20th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. <?php
  2. // Crate Register To Company.
  3. ob_start();
  4. include_once('wp-config.php');
  5. $conn = new mysqli(constant("DB_HOST"), constant("DB_USER"), constant("DB_PASSWORD"), constant("DB_NAME"));
  6. mysqli_query($conn , "SET character_set_client=utf8");
  7. mysqli_query($conn , "SET character_set_connection=utf8");
  8. mysqli_query($conn , "SET character_set_database=utf8");
  9. mysqli_query($conn , "SET character_set_results=utf8");
  10. mysqli_query($conn , "SET character_set_server=utf8");
  11.  
  12. if ($conn->connect_error) {
  13. die("Connection failed: " . $conn->connect_error);
  14. }
  15. mysqli_connect($conn);
  16. $statusMsg = '';
  17.  
  18.  
  19. $targetDir = WP_CONTENT_DIR . "/logos_company/";
  20. $fileName = basename($_FILES["file"]["name"]);
  21. $test = $_POST["test"];
  22. $targetFilePath = $targetDir . $fileName;
  23. $fileType = pathinfo($targetFilePath,PATHINFO_EXTENSION);
  24.  
  25. if(isset($_POST["submit"]) && !empty($_FILES["file"]["name"])){
  26.  
  27. $allowTypes = array('jpg','png','jpeg','gif','pdf');
  28. if(in_array($fileType, $allowTypes)){
  29.  
  30. if(move_uploaded_file($_FILES["file"]["tmp_name"], $targetFilePath)){
  31.  
  32. $conn->query("INSERT INTO Company_Users_Site (BusinessName, BusinessLogo) VALUES ('".$fileName."', '".$test."')") or die (mysql_error());
  33. $statusMsg = "The file ".$fileName." has been uploaded successfully.";
  34. header("Location: /asde");
  35. exit();
  36. }
  37. }
  38. }
  39.  
  40. echo <<<html
  41. <form action="" method="post" enctype="multipart/form-data">
  42. בחר תמונה להעלה : <input type="file" name="file">
  43. <br />
  44. כתוב תוכן לבדיקה : <input type="text" name="test">
  45. <br />
  46. <input type="submit" name="submit" value="Upload">
  47. </form>
  48. html;
  49.  
  50.  
  51. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement