473,396 Members | 1,726 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,396 software developers and data experts.

FTP Function just wont work! help!

Hey all,

First up, I am a newb, so go easy on me!

I am having issues with the FTP Function ... I have read MANY posts on
similar problems, but have found no fixes that seem to work (for me at
least) ...

I have pretty much cut and paste the FTP example from PHP.net. The
code connects to and logs into the FTP server fine, but never uploads
anything!

Bellow is my form code to retrieve the source file name :

++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++

<form name='ftpUpload' method='post' action='ftp.php'>
<input type='file' name='uploadFile'>
<br><br>
<input name='Upload' type='submit' value='Upload'>
</form>

++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++

And here is the code in 'ftp.php' :

++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++

// set up basic connection
$ftp_server="xxx.xxx.xxx.xxx";
$ftp_user_name="xxx";
$ftp_user_pass="xxx";
$source_file=$_POST['uploadFile'];
$destination_file="test.jpg";

$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 "<br>FTP connection has failed!";
echo "<br>Attempted to connect to '<b>$ftp_server</b>', as user
'<b>$ftp_user_name</b>'";
exit;
} else {
echo "<br>Connected to '<b>$ftp_server</b>', as user
'<b>$ftp_user_name</b>'";
}

// upload the file
$upload = ftp_fput($conn_id, $destination_file, $source_file,
FTP_BINARY);

// check upload status
if (!$upload) {
echo "<br>FTP upload has failed!";
} else {
echo "<br>Uploaded '<b>$source_file</b>' to
'<b>$ftp_server</b>' as '<b>$destination_file</b>'";
}

// close the FTP stream
ftp_close($conn_id);

++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++

The results are the same everytime. "FTP upload has failed!"

I have tried using $ftp_fput, but this generates the error "expects
parameter 3 to be resource".

So I tried opening the $source_file using :

$myFile = $fopen($source_file, 'r');
$upload = ftp_fput($conn_id, $destination_file, $myFile, FTP_BINARY);

but this returns the same error as above, and also states that the
source file does not exist - but in the location of 'ftp.php' on the
web server!! (as though I am trying to get the source file from thw
web server, despite the fact that the $source_file is the full path
and name of the file from the local machine. eg
C:\some_dir\some_file.jpg)

So what am I doing wrong? how can I get this to work? I am at a loss!

Cheers in advance,

Eclectic.
Jul 17 '05 #1
2 1718
"Eclectic" <ec*********@hotmail.com> wrote in message
news:c7**************************@posting.google.c om...
Hey all,

First up, I am a newb, so go easy on me!
Not a chance!
I am having issues with the FTP Function ... I have read MANY posts on
similar problems, but have found no fixes that seem to work (for me at
least) ...

I have pretty much cut and paste the FTP example from PHP.net. The
code connects to and logs into the FTP server fine, but never uploads
anything!
-snip-
So what am I doing wrong?
Not reading the manual!
how can I get this to work?


Read The F****** Manual

http://www.php.net/manual/en/features.file-upload.php

Jul 17 '05 #2
'RTFM' *blush*

cheers ... worked a treat ...
Jul 17 '05 #3

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

Similar topics

3
by: .: DeVa :. | last post by:
I made a script for loging into members area and have one problem im using functions() to declare procedures to do... And when i want to use some variable that is out of the function it doesent...
7
by: vegetax | last post by:
I i need a decorator that adds a local variable in the function it decorates, probably related with nested scopes, for example: def dec(func): def wrapper(obj = None): if not obj : obj = Obj()...
7
by: sindre | last post by:
Hi, Some place I use links to submit forms instead of a submit button. The way I have done this is: <a href="javascript:document.getElementById('<?php print "delete$i"...
7
by: Christine | last post by:
My code has a split function that should split the text file of numbers. I've run this in previous programs as it is here and it worked, but now it wont work for some reason and returns...
1
by: faultykid | last post by:
I would like to store a variable then call it back later. I have a variable on line 198 www = ''+this._ad.clickUrl+''; and on line 321 i try document.write(www);
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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,...

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.