Advertisement
Guest User

Untitled

a guest
Mar 7th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title></title>
  4. </head>
  5. <body>
  6. <!--?php
  7. ob_start();
  8.  
  9. if (isset($_POST['submitted']))
  10. {
  11. // get FTP access parameters
  12. $host = 'localhost';
  13. $user = 'test';
  14. $pass = 'password';
  15. $destDir = '../../uploads';
  16. $workDir = '../../tmp'; // define this as per local system
  17.  
  18. // get temporary file name for the uploaded file
  19. $tmpName = basename($_FILES['file']['tmp_name']);
  20.  
  21. // copy uploaded file into current directory
  22. move_uploaded_file($_FILES['file']['tmp_name'], $workDir."/".$tmpName)
  23. or die("Cannot move uploaded file to working directory");
  24.  
  25. // open connection
  26. $conn = ftp_connect($host) or die ("Cannot initiate connection to
  27. host");
  28.  
  29. // send access parameters
  30. ftp_login($conn, $user, $pass) or die("Cannot login");
  31.  
  32. // perform file upload
  33. $upload = ftp_put($conn, $destDir."/".$_FILES['file']['name'],
  34. $workDir."/".$tmpName, FTP_BINARY);
  35.  
  36. // check upload status
  37. // display message
  38. if (!$upload) {
  39. echo "Cannot upload";
  40. } else {
  41. echo "Upload complete";
  42. }
  43.  
  44. // close the FTP stream
  45. ftp_close($conn);
  46.  
  47. // delete local copy of uploaded file
  48. unlink($workDir."/".$tmpName) or die("Cannot delete uploaded
  49. file from working directory -- manual deletion recommended");
  50. }
  51. ?--> <form action="upload.php" enctype="multipart/form-data" method="post">
  52. <p>
  53. YouTube Username: <input type="text" /></p>
  54. <p>
  55. Video File: <input name="file" type="file" /></p>
  56. <p>
  57. <input name="submit" type="submit" value="Upload File" /> <input name="submitted" type="hidden" value="TRUE" /></p>
  58. </form>
  59. <!--?php
  60. ob_end_flush();
  61. ?--> </body>
  62. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement