Warning: ftp_put(): Filename invalid, PHP FTP Upload Script -
i've got error when tried upload files ftp server. i'm able connect ftp server, ftp_put(); keeps returning error message
this html form submission
<form action="upload_file.php" enctype="multipart/form-data" method="post"> <input name="file" type="file" /> <input name="submit" type="submit" value="upload file" /> </form>
and upload_file.php script
<?php $ftp_server = "xxx"; $ftp_user_name = "xxx"; $ftp_user_pass = "xxx"; $destination_file = "/iklan_output/". $_files["file"]["name"]; // returns /iklan_output/file.test $source_file = $_files["file"]["tmp_name"]; //decoy $new_src_file = "e:\\ta\\temp\\" . $_files["file"]["name"]; // directory file // set basic connection $conn_id = ftp_connect($ftp_server,20,900); // login username , password $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); // check connection if ((!$conn_id) || (!$login_result)) { echo "ftp connection has failed!"; echo "attempted connect $ftp_server user $ftp_user_name"; exit; } else { echo "connected $ftp_server, user $ftp_user_name"; } ftp_pasv($conn_id, true); // moves file temporary specific folder, used new source_file destination if ($_files["file"]["error"] > 0) { echo "error: " . $_files["file"]["error"] . "<br>"; } else { echo "upload: " . $_files["file"]["name"] . "<br>"; echo "type: " . $_files["file"]["type"] . "<br>"; echo "size: " . ($_files["file"]["size"] / 1024) . " kb<br>"; echo "stored in: " . $_files["file"]["tmp_name"]. "<br>"; if (file_exists("e:\\ta\\temp\\" . $_files["file"]["name"])) { echo $_files["file"]["name"] . " exists. "; } else { move_uploaded_file($_files["file"]["tmp_name"], "e:\\ta\\temp\\" . $_files["file"]["name"]); echo "temporarily stored in: " . "e:\\ta\\temp\\" . $_files["file"]["name"]. "<br>"; } } // upload file $upload = ftp_put($conn_id, $destination_file, $new_src_file, ftp_binary); // check upload status if (!$upload) { echo "ftp upload has failed!"; } else { echo "uploaded $source_file $ftp_server $destination_file"; } // close ftp stream ftp_close($conn_id); ?>
i've tried, , getting warning: ftp_put(): filename invalid error,
thank you!
update solved, code working, guys!
your destination file "/iklan_output/"
, not valid file name, directory name (because if trailing slash). try valid file name.
Warning: Ftp_Put(): Filename Invalid, Php Ftp Upload Script - >>>>> Download Now
ReplyDelete>>>>> Download Full
Warning: Ftp_Put(): Filename Invalid, Php Ftp Upload Script - >>>>> Download LINK
>>>>> Download Now
Warning: Ftp_Put(): Filename Invalid, Php Ftp Upload Script - >>>>> Download Full
>>>>> Download LINK FF