Advertisement
Guest User

Untitled

a guest
Jul 10th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. <?php
  2. // Form processing to validate and POST the value
  3.  
  4. // Start FTP Connection
  5. $ftp_server = "domain_name";
  6. $ftp_user_name = 'username';
  7. $ftp_user_pass = 'password';
  8. $file = $temp_fpath;
  9. $remote_file = "/public_html/staff/slip-gaji/uploads/" . $fname;
  10.  
  11. // set up a connection or die
  12. $conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");
  13.  
  14. // login with username and password
  15. $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
  16.  
  17. // turn passive mode on
  18. ftp_pasv($conn_id, true);
  19.  
  20. // upload a file
  21. if (ftp_put($conn_id, $remote_file, $file, FTP_BINARY)) {
  22. require '../../db_connection/connection-intra.php';
  23.  
  24. $sql = "INSERT INTO payment(
  25. dept, month, document, staff_id
  26. )
  27. VALUES (
  28. '$staff_dept', '$date', '$file_name', '$id'
  29. )";
  30.  
  31. if (mysqli_query($conn, $sql)) {
  32. echo "Upload success!";
  33. } else {
  34. echo "Error: " . $sql . "<br>" . mysqli_error($conn);
  35. }
  36.  
  37. mysqli_close($conn);
  38.  
  39. } else {
  40. echo "There was a problem while uploading $filen";
  41. }
  42.  
  43. // close the connection
  44. ftp_close($conn_id);
  45.  
  46. <?php
  47.  
  48. $servername = "localhost";
  49. $username = "root";
  50. $password = "";
  51. $dbname = "myDev";
  52.  
  53. // Create connection
  54. $conn = mysqli_connect($servername, $username, $password, $dbname);
  55.  
  56. // Check connection
  57. if (!$conn) {
  58. die("Connection failed: " . mysqli_connect_error());
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement