Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Checks connection to server
- $conn_id = ftp_connect($ftp_server);
- $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
- if(!$login_result || !is_writable($reltempfiledir))
- {$error = "Error connecting to $ftp_server or temp folder is not writable. Please contact the webmaster.";}
- else
- {
- if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $reltempfiledir . $filename))
- {
- $local_file = $reltempfiledir . $filename;
- //$file_handle = fopen( $tempfiledir . $filename, "w");
- //fwrite( $file_handle, $file_contents );
- //fclose( $file_handle );
- $file_handle = fopen($reltempfiledir . $filename, "r");
- //Places file in upload folder and gives success message
- if(ftp_fput($conn_id, "ha " . $filename, $file_handle, FTP_ASCII))
- {
- $success = 'Your file upload was successful!';
- $sql = "INSERT INTO `files` (`id`, `filename`, `filesize`, `display`, `user`, `labels`, `timestamp`) VALUES (NULL, \"" . $filename . "\", \"" . $filesize . "\", \"" . $display . "\", \"" . $_SESSION["firstname"] . " " . $_SESSION["lastname"] . "\", NULL, NULL);";
- $data = mysql_query($sql) or die(mysql_error());
- echo "<script>javascript:self.close()</script>";
- }
- else
- {$error = 'There was an error during the file upload. Upload Path: ' . $upload_path . $filename;}
- }
- }
Add Comment
Please, Sign In to add comment