<?php { $fileInfo = $_FILES['uploadedfile']; $filePath = $fileInfo['tmp_name']; $destination_path = "/.$fileName"; $ftp_server = "ftp://nazwaserwera.pl:21"; $connect_id = ftp_connect($ftp_server) or die("<h2>Couldn't connect to $ftp_server</h2>"); // Try connection $login_result = ftp_login($connect_id, $ftp_user_name, $ftp_user_pass) or die("<h2>You do not have access to this ftp server!</h2>"); if ((!connect_id) || (!login_result)) // Check Connection { exit; } else { } $upload = ftp_put($connect_id, $destination_path, $filePath, FTP_BINARY); if (!$upload) { } else { } ftp_close($connect_id); if (!$con) { } $sql="INSERT INTO upload (name, size, type, content, opis, date ) " . "VALUES ('$fileName', '$fileSize', '$fileType', '$content', '$opis', CURDATE())"; { } } ?> <html> <head></head> <body> Opis: <input type="text" name="opis" /> Wybierz plik: <input name="uploadedfile" type="file" id="uploadedfile" onChange="uploadedfileName.value=uploadedfile.value"/><br /><br> <input name="uploadedfileName" type="hidden" id="uploadedfileName" tabindex="99" size="1" /> <input type="submit" name="submit" value="Upload" /> <br> </form> </body>
Kod ma za zadanie wrzucać plik do folderu na ftp, a link do niego przechowywać w bazie. A tymczasem wyskakuje mi takie coś gdy uploaduje "502 Bad Gateway" co mogę zrobić z tym?