I'm trying to write a script for my users to be able to upload large
files, and now I am unsure what exactly I am doing wrong. My script
is based on the one in the PHP manual.
<?php
if(isset( $Submit ))
{
$ftp_server = "ftp_site";
$ftp_user_name = "username";
$ftp_user_pass = "password";
$source_file = $_FILES['imagefile']['name'];
$destination_fi le = "C:\\Progra~1\\ Ensim\\Sitedata \\jcmarko\\Inet pub\\wwwroot\\f ilevault\\ftp\\ "
.. $_FILES['imagefile']['tmp_name'];
// set up basic connection
$conn_id = ftp_connect($ft p_server);
// 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 <BR>";
}
// upload the file
ftp_pasv($conn_ id, TRUE);
$upload = ftp_put($conn_i d, $destination_fi le, $source_file,
FTP_BINARY);
// check upload status
if (!$upload) {
echo "FTP upload has failed!";
} else {
echo "Uploaded $source_file to $ftp_server as
$destination_fi le";
}
// close the FTP stream
ftp_close($conn _id);
}
?>
Some other notes/questions:
1. Is my format for the destination file variable correct? I've put
the complete path on my webhosters server to the directory I want my
users to upload to.
2. Because of some firewall problems, I need to put the transfer in
passive mode. Did I use ftp_pasv correctly?
3. Currently, my users can upload files, but it's through an HTTP
post and I would not like to do that anymore. Using the FTP commands
in PHP, is this still dependent on the settings in php.ini? Am I just
wasting my time if I can get my webhoster to modify their php.ini?
Any assistance as to what I am doing wrong would be greatly
appreciated!
-Joe
files, and now I am unsure what exactly I am doing wrong. My script
is based on the one in the PHP manual.
<?php
if(isset( $Submit ))
{
$ftp_server = "ftp_site";
$ftp_user_name = "username";
$ftp_user_pass = "password";
$source_file = $_FILES['imagefile']['name'];
$destination_fi le = "C:\\Progra~1\\ Ensim\\Sitedata \\jcmarko\\Inet pub\\wwwroot\\f ilevault\\ftp\\ "
.. $_FILES['imagefile']['tmp_name'];
// set up basic connection
$conn_id = ftp_connect($ft p_server);
// 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 <BR>";
}
// upload the file
ftp_pasv($conn_ id, TRUE);
$upload = ftp_put($conn_i d, $destination_fi le, $source_file,
FTP_BINARY);
// check upload status
if (!$upload) {
echo "FTP upload has failed!";
} else {
echo "Uploaded $source_file to $ftp_server as
$destination_fi le";
}
// close the FTP stream
ftp_close($conn _id);
}
?>
Some other notes/questions:
1. Is my format for the destination file variable correct? I've put
the complete path on my webhosters server to the directory I want my
users to upload to.
2. Because of some firewall problems, I need to put the transfer in
passive mode. Did I use ftp_pasv correctly?
3. Currently, my users can upload files, but it's through an HTTP
post and I would not like to do that anymore. Using the FTP commands
in PHP, is this still dependent on the settings in php.ini? Am I just
wasting my time if I can get my webhoster to modify their php.ini?
Any assistance as to what I am doing wrong would be greatly
appreciated!
-Joe