Newbie ftp_put
From: Bob Grover (xtooebb_at_yahoo.com)
Date: 06/30/04
- Next message: Andy Hassall: "Re: Making GD2 faster"
- Previous message: Geoff Berrow: "Re: Friend Connection Query"
- Next in thread: Michael Austin: "Re: Newbie ftp_put"
- Reply: Michael Austin: "Re: Newbie ftp_put"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 30 Jun 2004 10:48:40 -0700
I would like to pass the source file name to the destination file in
an ftp_put operation, but for the life of me, cannot figure out how to
do this. I have an input form and php script which work fine, but the
destination file is always named sample.wav. If someone could help me
out, I would really appreciate it.
-------------------------------
my html form, upload.html:
-------------------------------
<html>
<head><title>File Upload</title></head>
<body>
<form name="Attachments" enctype="multipart/form-data"
action="upload.php" method="post">
<table border="0" cellpadding="15" align="center" width=""
align="center">
<tr><td align="center"><h2>File Upload</h2></td></tr>
<tr><td>
<table border="0" cellpadding="15" align="center" width=""
align="center">
<tr><td align="center">Please use the controls below to upload your
file. You will be presented with a confirmation page when the upload
has
completed.</td></tr>
<tr><td>
<table border="0" align="center" cellpadding="10">
<tr><td><input type=hidden name=box value=""></td></tr>
<tr><td><input type=file name=source_file size=20></td></tr>
<tr><td colspan=2 align="center">
<input type="hidden" name="sessionid" value="<?= $sid ?>">
<input type="submit" name=btnSubmit value=" Upload ">
</td></tr></table>
</td>
</tr>
<tr><td>
< align="center">Please visit <a
href="http://www.ourdomain.com/?
dn">http://www.ourdomain.com>.
</p>
</table>
</form>
</body>
</html>
-------------------------------
my php script, upload.php:
-------------------------------
<?php
$ftp_server='xx.xxx.xxx.xx';//serverip
$conn_id = ftp_connect($ftp_server);
// login with username and password
$user="username";
$passwd="password";
$login_result = ftp_login($conn_id, $user, $passwd);
// check connection
if ((!$conn_id) || (!$login_result)) {
echo "FTP connection has failed!";
echo "Attempted to connect to $ftp_server for user
$ftp_user_name";
die;
} else {
echo "<br>Connected to $ftp_server, for user $user<br>";
}
//change upload directory to another user's group writable directory
ftp_chdir($conn_id, "/home/otheruser/files");
//set destination filename
$destination_file="sample.wav";
echo ("<br>");
print $destination_file;
echo ("<br>");
// 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);
?>
--------------------------
added to my .htaccess file:
--------------------------
php_value max_execution_time 2500
php_value memory_limit 200M
php_value post_max_size 200M
php_value upload_max_filesize 200M
Options -Indexes
- Next message: Andy Hassall: "Re: Making GD2 faster"
- Previous message: Geoff Berrow: "Re: Friend Connection Query"
- Next in thread: Michael Austin: "Re: Newbie ftp_put"
- Reply: Michael Austin: "Re: Newbie ftp_put"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]