Guest User

Untitled

a guest
Jun 14th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. //Checks connection to server
  2. $conn_id = ftp_connect($ftp_server);
  3.  
  4. $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
  5.  
  6. if(!$login_result || !is_writable($reltempfiledir))
  7. {$error = "Error connecting to $ftp_server or temp folder is not writable. Please contact the webmaster.";}
  8. else
  9. {
  10. if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $reltempfiledir . $filename))
  11. {
  12. $local_file = $reltempfiledir . $filename;
  13.  
  14. //$file_handle = fopen( $tempfiledir . $filename, "w");
  15. //fwrite( $file_handle, $file_contents );
  16. //fclose( $file_handle );
  17.  
  18. $file_handle = fopen($reltempfiledir . $filename, "r");
  19.  
  20. //Places file in upload folder and gives success message
  21. if(ftp_fput($conn_id, "ha " . $filename, $file_handle, FTP_ASCII))
  22. {
  23. $success = 'Your file upload was successful!';
  24. $sql = "INSERT INTO `files` (`id`, `filename`, `filesize`, `display`, `user`, `labels`, `timestamp`) VALUES (NULL, \"" . $filename . "\", \"" . $filesize . "\", \"" . $display . "\", \"" . $_SESSION["firstname"] . " " . $_SESSION["lastname"] . "\", NULL, NULL);";
  25. $data = mysql_query($sql) or die(mysql_error());
  26. echo "<script>javascript:self.close()</script>";
  27. }
  28. else
  29. {$error = 'There was an error during the file upload. Upload Path: ' . $upload_path . $filename;}
  30. }
  31. }
Add Comment
Please, Sign In to add comment