Tilted Forum Project Discussion Community  

Go Back   Tilted Forum Project Discussion Community > Interests > Tilted Technology


 
 
LinkBack Thread Tools
Old 03-24-2005, 01:05 PM   #1 (permalink)
Too hot in the hot tub!
 
pixelbend's Avatar
 
[php]FTP upload script

Hi all,

I am writing an FTP upload script and I'm having a weird problem. I wrote it and tested it by uploading the html and php files that make up the script. It will transfer either of those fine, but any other file I try errors out. Heres the code:

Code:
<?php

	//Magna-Tel FTP Upload site
	
	//get variables from form
	$cust = $_POST["customer"];
	$name = $_POST["name"];
	$email = $_POST["email"];
	$ponum = $_POST["ponum"];
	$file = $_POST["file"];
	
	$dest_file = $ponum . "_" . $file;
	
	//Check to see all input is present
	if ($cust == "") echo "<p>Customer name missing!";
	else if($name == "") echo "<p>Name missing!";
	else if($email == "") echo "<p>Email missing!";
	else if($file == "") echo "<p>File name missing!";
	
	//Connect to ftp server
	$ftp_server = "pop3.magna-tel.net";
	$ftp_user_name = "ftpuser";
	$ftp_user_pass = "upload";
	
	$conn_id = ftp_connect($ftp_server);
	$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
	
	// check connection
	if ((!$conn_id) || (!$login_result)) {
		echo "<p>FTP connection has failed!";
		echo "<p>Attempted to connect to $ftp_server for user $ftp_user_name";
		exit;
	}
	else {
		echo "<p>Connected to $ftp_server, for user $ftp_user_name";
	}
	
	// upload the file
	$upload = ftp_put($conn_id, $dest_file, $file, FTP_BINARY);

	// check upload status
	if (!$upload) {
		echo "<p>FTP upload has failed!";
	}
	else {
		echo "<p>Uploaded $file to $ftp_server as $dest_file";
	}

	// close the FTP stream
	ftp_close($conn_id);
	
	//Email art@magna-tel.net and customer with notice
	$art_email = "art@magna-tel.net";
	$art_subject = "FTP file has been uploaded";
	$art_body = "$name from $cust has uploaded file $file to the FTP server.\nPlease check as soon as possible.";
	$art_return = "From:davidg@magna-tel.net";
	
	if ($upload) mail ($art_email, $art_subject, $art_body, $art_return);

?>
I get the "FTP upload has failed!" on all files except upload.php and upload.html
__________________
But I don't want ANY Spam!
pixelbend is offline  
Old 03-26-2005, 08:18 PM   #2 (permalink)
Crazy
 
Location: here and there
I guess what look suspicious to me is you are using ftp to connect to a mail server. Is this really what you want to do?
__________________
# chmod 111 /bin/Laden
theFez is offline  
Old 04-07-2005, 08:04 AM   #3 (permalink)
Insane
 
Location: Austin, TX
Check your apache error log. Usually there will be some more verbose information there.
skaven is offline  
Old 04-07-2005, 09:00 AM   #4 (permalink)
Too hot in the hot tub!
 
pixelbend's Avatar
 
Got it working. I was not using the proper front end (that was my main problem anyway) on the html side.
__________________
But I don't want ANY Spam!
pixelbend is offline  
 

Tags
phpftp, script, upload


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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 02:55 PM.

Tilted Forum Project

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62