Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title></title>
- </head>
- <body>
- <!--?php
- ob_start();
- if (isset($_POST['submitted']))
- {
- // get FTP access parameters
- $host = 'localhost';
- $user = 'test';
- $pass = 'password';
- $destDir = '../../uploads';
- $workDir = '../../tmp'; // define this as per local system
- // get temporary file name for the uploaded file
- $tmpName = basename($_FILES['file']['tmp_name']);
- // copy uploaded file into current directory
- move_uploaded_file($_FILES['file']['tmp_name'], $workDir."/".$tmpName)
- or die("Cannot move uploaded file to working directory");
- // open connection
- $conn = ftp_connect($host) or die ("Cannot initiate connection to
- host");
- // send access parameters
- ftp_login($conn, $user, $pass) or die("Cannot login");
- // perform file upload
- $upload = ftp_put($conn, $destDir."/".$_FILES['file']['name'],
- $workDir."/".$tmpName, FTP_BINARY);
- // check upload status
- // display message
- if (!$upload) {
- echo "Cannot upload";
- } else {
- echo "Upload complete";
- }
- // close the FTP stream
- ftp_close($conn);
- // delete local copy of uploaded file
- unlink($workDir."/".$tmpName) or die("Cannot delete uploaded
- file from working directory -- manual deletion recommended");
- }
- ?--> <form action="upload.php" enctype="multipart/form-data" method="post">
- <p>
- YouTube Username: <input type="text" /></p>
- <p>
- Video File: <input name="file" type="file" /></p>
- <p>
- <input name="submit" type="submit" value="Upload File" /> <input name="submitted" type="hidden" value="TRUE" /></p>
- </form>
- <!--?php
- ob_end_flush();
- ?--> </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement