FTP Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsSystem AdministrationFTP Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 9th, 2003, 04:25 AM
jamesf4218 jamesf4218 is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2001
Location: England
Posts: 673 jamesf4218 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 27 m
Reputation Power: 8
FTP name problem

Hello,

I have the FTP script off php.net:

PHP Code:
<?php

$ftp_server 
'x.x.x.x.x';
$ftp_user_name 'blah';
$ftp_user_pass 'foo';
$destination_file '/public_html/$userfile';
$source_file $userfile;

// set up basic connection
$conn_id ftp_connect($ftp_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";
    }

// upload the file
$upload ftp_put($conn_id$destination_file$source_fileFTP_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); 
?>


I am passing through $userfile from a form on the previous page.

The upload works fine but instead of uploading the file with the filename, it uploads the file and calls it $userfile instead of the actual filename.

Why is this? How do I make this work?

Cheers,

James

Reply With Quote
  #2  
Old May 9th, 2003, 04:39 AM
Maldor's Avatar
Maldor Maldor is offline
Muhhnnn !!
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Apr 2003
Posts: 1,530 Maldor User rank is Second Lieutenant (5000 - 10000 Reputation Level)Maldor User rank is Second Lieutenant (5000 - 10000 Reputation Level)Maldor User rank is Second Lieutenant (5000 - 10000 Reputation Level)Maldor User rank is Second Lieutenant (5000 - 10000 Reputation Level)Maldor User rank is Second Lieutenant (5000 - 10000 Reputation Level)Maldor User rank is Second Lieutenant (5000 - 10000 Reputation Level)Maldor User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 7 h 38 m 2 sec
Reputation Power: 83
PHP Code:
 $destination_file "/public_html/$userfile";
$source_file $userfile


PHP Code:
 $destination_file '/public_html/'.$userfile;
$source_file $userfile


Both of those should be fine... using '/public_html/$userfile' inhibit the string parsing so the variable is not replaced.

Also, I would highly suggest you to use :

PHP Code:
 $destination_file '/public_html/'.$_POST["userfile"];
$source_file $_POST["userfile"]; 


Then you will not have problems with the fact the register global option can be turned off.
__________________
"The ultimate knowledge is reached when it does not bring new questions..."
-- Usaphdas encyclopedia XV.4


Reply With Quote
  #3  
Old May 9th, 2003, 04:41 AM
Maldor's Avatar
Maldor Maldor is offline
Muhhnnn !!
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Apr 2003
Posts: 1,530 Maldor User rank is Second Lieutenant (5000 - 10000 Reputation Level)Maldor User rank is Second Lieutenant (5000 - 10000 Reputation Level)Maldor User rank is Second Lieutenant (5000 - 10000 Reputation Level)Maldor User rank is Second Lieutenant (5000 - 10000 Reputation Level)Maldor User rank is Second Lieutenant (5000 - 10000 Reputation Level)Maldor User rank is Second Lieutenant (5000 - 10000 Reputation Level)Maldor User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 7 h 38 m 2 sec
Reputation Power: 83
oh, and you should replace $_POST par $_GET accordingly to what kind of method your form is using...

Reply With Quote
  #4  
Old May 9th, 2003, 04:53 AM
jamesf4218 jamesf4218 is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2001
Location: England
Posts: 673 jamesf4218 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 27 m
Reputation Power: 8
thanks that works

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationFTP Help > FTP name problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway