Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $submit = $_POST['submit'];
- if ($submit) {
- //set to absolute path, make sure folder has write permissions
- $uploaddir = '/var/www/uploads/';
- $uploadfile = $uploaddir . basename($_FILES['file']['name']);
- move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile);
- $ftp_server = "HIDDEN";
- $ftp_user = "HIDDEN";
- $ftp_pass = "HIDDEN";
- $file = $_FILES["file"]["name"];
- // set up basic connection
- $conn_id = ftp_connect($ftp_server);
- // login with username and password
- $login_result = ftp_login($conn_id, $ftp_user, $ftp_pass);
- // upload a file
- if (ftp_put($conn_id, $file, $uploadfile, FTP_ASCII)) {
- echo "Successfully uploaded $file\n";
- } else {
- echo "There was a problem while uploading $file\n";
- }
- // close the connection
- ftp_close($conn_id);
- } else {
- echo 'Press the button!';
- }
- ?>
- <html>
- <body>
- <form action="" method="post" enctype="multipart/form-data">
- <label for="file">Filename:</label>
- <input type="file" name="file" id="file" />
- <br />
- <input type="submit" name="submit" value="Submit" />
- </form>
- </body>
- </html>
Add Comment
Please, Sign In to add comment