Forum Moderators: coopster
Error
---------
Warning: ftp_put(batch file.txt) [function.ftp-put]: failed to open stream: No such file or directory in C:\Inetpub\wwwroot\ghost\admin\serials\uploadfile.php on line 26
upload.php
-------------
<form action="uploadfile.php" method="post" enctype="multipart/form-data" name="form1" >
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>File name </td>
<td><input type="file" name="file"><input type="submit" name="Submit" value="Upload"></td>
</tr>
</table>
</form>
uploadfile.php
----------------
error_reporting(E_ALL);
ini_set('display_errors','On');
$ftp_user_name='prod-wsus\ghost';
$ftp_user_pass='password';
$ftp_server='ghost.utsi.local';
$source_file=$_FILES['file']['name'];
$destination_file=$source_file;
$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id , $ftp_user_name , $ftp_user_pass);
if((!$conn_id)¦¦(!$login_result))
{
echo "FTP connection has failed!" ;
echo "Attempted to connect to $ftp_server for user $ftp_user_name" ;
exit;
}
else
{
echo "Connected to $ftp_server, for user $ftp_user_name" ;
}
$upload = ftp_put($conn_id,$destination_file,$source_file,FTP_ASCII); <--- This is line 26
if(!$upload)
{
echo " FTP upload has failed!" ;
}
else
{
echo "Uploaded $source_file to $ftp_server as $destination_file" ;
}
ftp_close($conn_id);
Your form uploads the file (via HTTP) to a temporary location $_FILES['file']['tmp_name'] (governed by your server). I think you then need to call move_uploaded_file() to move this file to a slightly more permanent location on your server before you can then use this file to ftp_put it to a different server.