473,406 Members | 2,345 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

FTP question

Ok Its getting late and i am getting tired. what stupid mistake am I making
here:

<?php
$filepath = $_REQUEST['filepath']; // this is the path to say music/preview
or /cd_covers
$ftp_server = 'ftp.XXXXX.co.uk';
$ftp_user_name = 'xxxxxxx';
$ftp_user_pass = 'xxxxxxxx';
$file = $_FILES['userfile']['name'];
$remote_file = $filepath.$file;
// set up a connection or die
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to
$ftp_server");
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass) or
die("login failed"); // logs the user or sets an error message

if(ftp_chdir($conn_id, $filepath)){
}else{
echo "Directory doesnot exist";
exit;
}
// upload a file\
if (ftp_put($conn_id, $remote_file, $file, FTP_BINARY)) {
echo "successfully uploaded $file\n";
} else {
echo "There was a problem while uploading $file\n";
}

ftp_close($conn_id);
?>
straight out of the manual what gives?
Cheers Richard
Jul 17 '05 #1
5 1662
Richard Hulbert wrote:
Ok Its getting late and i am getting tired. what stupid mistake am I
making here:

<code snip>

The actual error message or what ever would be helpful.

~Cameron
Jul 17 '05 #2
Richard Hulbert wrote:
Ok Its getting late and i am getting tired. what stupid mistake am I making
here:

<?php
$filepath = $_REQUEST['filepath']; // this is the path to say music/preview
or /cd_covers
$ftp_server = 'ftp.XXXXX.co.uk';
$ftp_user_name = 'xxxxxxx';
$ftp_user_pass = 'xxxxxxxx';
$file = $_FILES['userfile']['name'];
$remote_file = $filepath.$file;

(snip)

if I update a file named XXX, seems like $remote_file will have either
music/previewXXX or /cd_coversXXX

Are you sure that is what you want?
What exact error do you get? At which instruction?

This is like asking us to guess what is the license plate on your car
just be telling us it's a FOOBAR model!
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #3
On 2004-02-23 19:06:53 +0000, Pedro Graca <he****@hotpop.com> said:
Are you sure that is what you want?
What exact error do you get? At which instruction?

This is like asking us to guess what is the license plate on your car
just be telling us it's a FOOBAR model!
-- --= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--

Firstly Thanks for answering.

Ok Sorry let me step back a bit. firstly here is what i am trying to do:

I am building a CMS that needs to upload two supporting files to
directories on the public server. I want to do this from another site, at
the moment I am doing this from localhost on my dev machine.

I thought FTP option would be better in terms of preventing php actually
writing files to the server.

Ok so the Error - I don't get an error as such, i connect in, can navigate
directories,etc it is the last call that is giving me a problem.

if (ftp_put($conn_id, $remote_file, $file, FTP_BINARY)) {
echo "successfully uploaded $file\n";
} else {
echo "There was a problem while uploading $file\n";
}

now $remote file is a string right? somthing like /music/previews/abc.mp3
and $file is from $file = $_FILES['userfile']['name'];

basically ftp_put fails and I Echo There was a problem...

am i missunderstanding how to use the $_FILES object in this context?
thanks Richard

Jul 17 '05 #4
SNIP

aha I have was indeed missing how to reference the file object. so to make
it all work really well.

$upload = (ftp_put($conn_id, $filepath . $_FILES['userfile']['name'],
$_FILES['userfile']['tmp_name'], FTP_BINARY));

the key being $_FILES['userfile']['tmp_name']

i am now going to write one hundred times 'php references everything from
the server !'

thanks Richard
Jul 17 '05 #5
> i am now going to write one hundred times 'php references everything
from the server !'


Nah, just write a loop with a counter and that'll do it. ;)

- Dan
http://blog.dantripp.com/
Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mohammed Mazid | last post by:
Can anyone please help me on how to move to the next and previous question? Here is a snippet of my code: Private Sub cmdNext_Click() End Sub Private Sub cmdPrevious_Click() showrecord
3
by: Stevey | last post by:
I have the following XML file... <?xml version="1.0"?> <animals> <animal> <name>Tiger</name> <questions> <question index="0">true</question> <question index="1">true</question> </questions>
7
by: nospam | last post by:
Ok, 3rd or is it the 4th time I have asked this question on Partial Types, so, since it seems to me that Partial Types is still in the design or development stages at Microsoft, I am going to ask...
3
by: Ekqvist Marko | last post by:
Hi, I have one Access database table including questions and answers. Now I need to give answer id automatically to questionID column. But I don't know how it is best (fastest) to do? table...
10
by: glenn | last post by:
I am use to programming in php and the way session and post vars are past from fields on one page through to the post page automatically where I can get to their values easily to write to a...
10
by: Rider | last post by:
Hi, simple(?) question about asp.net configuration.. I've installed ASP.NET 2.0 QuickStart Sample successfully. But, When I'm first start application the follow message shown. ========= Server...
53
by: Jeff | last post by:
In the function below, can size ever be 0 (zero)? char *clc_strdup(const char * CLC_RESTRICT s) { size_t size; char *p; clc_assert_not_null(clc_strdup, s); size = strlen(s) + 1;
56
by: spibou | last post by:
In the statement "a *= expression" is expression assumed to be parenthesized ? For example if I write "a *= b+c" is this the same as "a = a * (b+c)" or "a = a * b+c" ?
2
by: Allan Ebdrup | last post by:
Hi, I'm trying to render a Matrix question in my ASP.Net 2.0 page, A matrix question is a question where you have several options that can all be rated according to several possible ratings (from...
3
by: Zhang Weiwu | last post by:
Hello! I wrote this: ..required-question p:after { content: "*"; } Corresponding HTML: <div class="required-question"><p>Question Text</p><input /></div> <div...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.