Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Form processing to validate and POST the value
- // Start FTP Connection
- $ftp_server = "domain_name";
- $ftp_user_name = 'username';
- $ftp_user_pass = 'password';
- $file = $temp_fpath;
- $remote_file = "/public_html/staff/slip-gaji/uploads/" . $fname;
- // set up a connection or die
- $conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");
- // login with username and password
- $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
- // turn passive mode on
- ftp_pasv($conn_id, true);
- // upload a file
- if (ftp_put($conn_id, $remote_file, $file, FTP_BINARY)) {
- require '../../db_connection/connection-intra.php';
- $sql = "INSERT INTO payment(
- dept, month, document, staff_id
- )
- VALUES (
- '$staff_dept', '$date', '$file_name', '$id'
- )";
- if (mysqli_query($conn, $sql)) {
- echo "Upload success!";
- } else {
- echo "Error: " . $sql . "<br>" . mysqli_error($conn);
- }
- mysqli_close($conn);
- } else {
- echo "There was a problem while uploading $filen";
- }
- // close the connection
- ftp_close($conn_id);
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "myDev";
- // Create connection
- $conn = mysqli_connect($servername, $username, $password, $dbname);
- // Check connection
- if (!$conn) {
- die("Connection failed: " . mysqli_connect_error());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement