473,513 Members | 2,654 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ftp upload error

hi all

i posted a little while ago about this, but am getting no further ahead.
does anybody have a clue as to why this script doesn't upload my files any
longer (all it does is stick a 1kb file on the server which can't be read).
i'm not sure if the script thinks the file is only 1kb large or if the
problem is somewhere else. the server is freeBSD, PHP version 4. any
ideas? tks.

if(isSet($_POST['cmdUpload'])){
$sTargetDir = trim($HTTP_POST_VARS['destDir']);
$sOriginalFileName = $HTTP_POST_FILES['srcFile']['name'];
$sImgPrefix = trim($HTTP_POST_VARS['imgCategory']);
if($sTargetDir == "/public_html/images/" || $sTargetDir ==
"/public_html/ezine/images/"){ // it's an image - attach the image category
prefix //
$sFileName = $sImgPrefix . str_replace(" ", "_", $sOriginalFileName);
}
else{
$sFileName = str_replace(" ", "_", $sOriginalFileName);
}
$sFolder = str_replace("/public_html/", "", $sTargetDir);
$sFullDestinationPath = $sTargetDir . $sFileName;
if($_POST['destDir'] == ""){
die("Error: No destination directory selected. Upload aborted. Please
click your back button and try again.");
}
else{
$oFTPConn = ftp_connect($sFtpServer,21,9600) or die("Unable to connect to
$sFTPServer!"); //login to the ftp server and upload the file //
$cmdLogin = ftp_login($oFTPConn, $sFtpUserName, $sFtpPassWord) or
die("Unable to connect to login to the FTP server: $sFTPServer!");
$cmdUpload = FTP_NB_PUT($oFTPConn, $sFullDestinationPath,
$_POST['srcFile'], FTP_BINARY);
while ($cmdUpload == FTP_MOREDATA){
$cmdUpload = FTP_NB_CONTINUE($oFTPConn);
}
$cmdCloseFTP = ftp_close($oFTPConn);
if (!$cmdUpload){ //check to see if the file was successfully uploaded //
$sResponseMsg = "<h1>Error</h1><p>Unable to upload file to server.</p>";
}
else{
$sResponseMsg = "<span style='text-decoration:
underline;'>$sFileName</span> was uploaded successfull to $sTargetDir.";
}
}
}
Jul 17 '05 #1
2 1854
Nancy Drew wrote:
does anybody have a clue as to why this script doesn't upload my files any
longer (all it does is stick a 1kb file on the server which can't be read).
i'm not sure if the script thinks the file is only 1kb large or if the
problem is somewhere else. the server is freeBSD, PHP version 4. any
ideas? tks.
<snip> $sOriginalFileName = $HTTP_POST_FILES['srcFile']['name']; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
<snip> $cmdUpload = FTP_NB_PUT($oFTPConn, $sFullDestinationPath,
$_POST['srcFile'], FTP_BINARY);

^^^^^^^^^^^^^^^^^
<snip>

Isn't < $_POST['scrFile'] > an array?

Doesn't ftp_nb_put() take a string as its third parameter?

When you have an array and treat is as a string the result can be
misleading :-)

--
Mail to my "From:" address is readable by all at http://www.dodgeit.com/
== ** ## !! ------------------------------------------------ !! ## ** ==
TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>)
may bypass my spam filter. If it does, I may reply from another address!
Jul 17 '05 #2

"Pedro Graca" <he****@dodgeit.com> wrote in message
news:sl*******************@ID-203069.user.uni-berlin.de...
Nancy Drew wrote:
does anybody have a clue as to why this script doesn't upload my files any longer (all it does is stick a 1kb file on the server which can't be read). i'm not sure if the script thinks the file is only 1kb large or if the
problem is somewhere else. the server is freeBSD, PHP version 4. any
ideas? tks.
<snip>
$sOriginalFileName = $HTTP_POST_FILES['srcFile']['name'];

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
<snip>
$cmdUpload = FTP_NB_PUT($oFTPConn, $sFullDestinationPath,
$_POST['srcFile'], FTP_BINARY);

^^^^^^^^^^^^^^^^^
<snip>

Isn't < $_POST['scrFile'] > an array?


yeah, that was the problem. tks pedro.
Doesn't ftp_nb_put() take a string as its third parameter?

When you have an array and treat is as a string the result can be
misleading :-)

--
Mail to my "From:" address is readable by all at http://www.dodgeit.com/
== ** ## !! ------------------------------------------------ !! ## ** ==
TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>)
may bypass my spam filter. If it does, I may reply from another address!

Jul 17 '05 #3

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

Similar topics

3
11739
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a...
15
5303
by: David Lozzi | last post by:
Howdy, I have a function that uploads an image and that works great. I love ..Nets built in upload, so much easier than 3rd party uploaders! Now I am making a public function that will take the...
0
4739
by: SEMIH DEMIR | last post by:
Sitelerden birinde verilen yabancı kaynakli bir scriptti duzenledim yanlız birseyin içinden bir turlu cıkamadım işin aslı ilk defa persistin upload componentini kullanacam yanlız suanki haliyle...
9
3815
by: Wayne Smith | last post by:
I've come up against a major headache that I can't seem to find a solution for but I'm sure there must be a workaround and I would really be grateful of any help. I'm currently building a web...
9
20878
by: 8anos | last post by:
Hello, I am new at the community and newbie at programming :) As you may know rapidshare provides a perl script for linux, to upload files at their servers. You can find the original scripts at...
2
2141
by: Event Horizon | last post by:
Hi, I'm trying to add an simple upload applet to shopping cart script. My new applet form sends all needed post fields ( quantity, product, etc... ) but the "file" post field is hardcoded in...
21
34328
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
5
3265
by: camphor | last post by:
hi, I have found an upload script in hotscripts and have implemented it into the website, I followed the installation steps to 'give write permissions to php on the upload folder (which is...
5
6792
by: kailashchandra | last post by:
I am trying to upload a file in php,but it gives me error msg please Help me? My Code is like below:- i have one php file named upload.php and i have another html file named upload.html and...
1
4862
by: chennaibala | last post by:
can any one send me mutiple image upload program and save the file name with extension in mysql table.we must cheak uploaded file type like bmp or any image file while uploading. i develop...
0
7257
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
7157
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7535
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...
1
7098
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
7521
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...
1
5084
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...
0
4745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3232
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.