This is a discussion on PHP FTP QUESTION within the PHP General forums, part of the PHP Programming Forums category; Hello all. I'm a newbie at this and cannot figure out why the $source_file will not carry over from ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hello all. I'm a newbie at this and cannot figure out why the
$source_file will not carry over from the html page. I am geting this error. Notice: Undefined variable: source_file in c:\dev\handle_ftp.php on line 30 FTP upload has failed! -Any help or suggestions I would greatly appreciate!!! ------------------------------------------------ this is the html page <html> <body marginwidth=4 marginheight=4 topmargin=4 leftmargin=4 bgcolor=white vlink="#0000ff" link="#0000ff"> <form name="Attachments" method=POST action="handle_ftp.php" enctype="multipart/form-data"> <input type=hidden name=box value=""> <tr> <td nowrap width="1%"> <b>Image:</b></td> <td colspan=2> <input type=file name=source_file size=20> <br> </td> </tr> <input type=submit name=btnSubmit value=Submit size=20 style="border: 1px solid #0000FF"> </form> </body> </html> ------------------------------------------------------------ this is the php handling code <?php $ftp_server = "xxx"; $ftp_user_name = "xxx"; $ftp_user_pass = "xxx"; //puts file in current directory //$destination_file=ftp_pwd($conn_id); // set up basic connection $conn_id = ftp_connect($ftp_server); //var_dump($source_file); //exit; // login with username and 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 to connect to $ftp_server for user $ftp_user_name"; exit; } else { echo "Connected to $ftp_server, for user $ftp_user_name"; } // upload the file $upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY); // check upload status if (!$upload) { echo "FTP upload has failed!"; } else { echo "Uploaded $source_file to $ftp_server as $destination_file"; } // close the FTP stream ftp_close($conn_id); ?> |
|
|||
|
<baustin75@gmail.com> wrote in message news:1166537391.573311.265040@79g2000cws.googlegro ups.com... > Hello all. I'm a newbie at this and cannot figure out why the > $source_file will not carry over from the html page. I am geting this > error. > > Notice: Undefined variable: source_file in c:\dev\handle_ftp.php on > line 30 > FTP upload has failed! > > -Any help or suggestions I would greatly appreciate!!! > > ------------------------------------------------ > this is the html page > > > <html> > > <body marginwidth=4 marginheight=4 topmargin=4 leftmargin=4 > bgcolor=white vlink="#0000ff" link="#0000ff"> > > <form name="Attachments" method=POST action="handle_ftp.php" > enctype="multipart/form-data"> > > <input type=hidden name=box value=""> > > <tr> > <td nowrap width="1%"> <b>Image:</b></td> > <td colspan=2> > <input type=file name=source_file size=20> <br> > > > > </td> > </tr> > <input type=submit name=btnSubmit value=Submit size=20 style="border: > 1px solid #0000FF"> > </form> > </body> > </html> > ------------------------------------------------------------ > this is the php handling code > > <?php > > $ftp_server = "xxx"; > $ftp_user_name = "xxx"; > $ftp_user_pass = "xxx"; > > > //puts file in current directory > //$destination_file=ftp_pwd($conn_id); > > // set up basic connection > $conn_id = ftp_connect($ftp_server); > > //var_dump($source_file); > //exit; > > // login with username and 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 to connect to $ftp_server for user > $ftp_user_name"; > exit; > } else { > echo "Connected to $ftp_server, for user $ftp_user_name"; > } > $source_file = $_POST['source_file']; > // upload the file > $upload = ftp_put($conn_id, $destination_file, $source_file, > FTP_BINARY); > > // check upload status > if (!$upload) { > echo "FTP upload has failed!"; > } else { > echo "Uploaded $source_file to $ftp_server as > $destination_file"; > } > > // close the FTP stream > ftp_close($conn_id); > ?> > Add $source_file = $_POST['source_file']; Where I have indicated and that should sort it for you. The problem is that you haven't transferred the values from the form to the variable in your PHP. Sean |