Problems with php ftp uploader

Hi,

I’m currently trying to create a ftp uploader for the company website, so we can recieve artwork from clients, however it isn’t working can anyone look at the script and see where its going wrong. I’ve looked at loads of tutorials but it still wont work.

cheers


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<?php
$file_dir = "/public_html/ftp";
$file_url = "http://www.iceni.tv/ftp";

foreach( $HTTP_POST_FILES as $file_name => $file_array) {
	print "path: ".$file_array['tmp_name']."<br>
";
	print "name: ".$file_array['name']."<br>
";
	print "type: ".$file_array['type']."<br>
";
	print "size: ".$file_array['size']."<br>
";
	
	if (is_uploaded_file( $file_array['tmp_name'] )
	&& $file_array['type'] == "image/gif" ) {
	move_uploaded_file( $file_array['tmp_name'], "$file_dir/$file_name")
		or die ("couldn't copy");
	print "<img src=\"$file_url/$file_name\"><p>

";
	}
}
?>
<body>
<form encrpt="multipart/form-data" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="51200">
<input type="file" name="fupload"><br>
<input type="submit" value="upload!">
</form>
</body>
</html>

Why using an array ?

try this… and see if it works


 #simple test
  <?php
  $ftp_user_name ='';
  $ftp_user_pass ='';
  $ftp_server='';
  
   // open some file for reading
  $file = 'somefile.txt';
  $fp = fopen($file, 'r');
  
  // set up basic connection
  $conn_id = ftp_connect($ftp_server) 
 or die ("Ftp server connection failed:);
  
  // login with username and password
  $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass) 
 or die ("user / password not correct");
  
  // try to upload $file
  if (ftp_fput($conn_id, $file, $fp, FTP_ASCII)) {
     echo "Successfully uploaded $file
";
  } else {
     echo "There was a problem while uploading $file
";
  }
  
  // close the connection and the file handler
  ftp_close($conn_id);
  fclose($fp);
  
  ?> 

 #server 2 server ..
 <?php
 $FTP_HOST ="ftp.host.com"; 
 $FTP_USER ="user";
 $FTP_PW   ="mypasswd";
 $FTP_ROOT_DIR="/";
 $LOCAL_SERVER_DIR  = "images/";
 $FTP_DIR = "mydir/";
 $handle=opendir($LOCAL_SERVER_DIR);
 while (($file = readdir($handle))!==false)
 {
     if(!is_dir($file)){
 	    $f[]="$file";		
 	  }
 }
 closedir($handle);
 sort($f);
 $count=0;
 $mode = FTP_BINARY; // or FTP_ASCII
 $conn_id = ftp_connect($FTP_HOST); 
 if(ftp_login($conn_id, $FTP_USER, $FTP_PW)){
     print "from: ".$LOCAL_SERVER_DIR."<br>";
     print "to: ".$FTP_HOST.$FTP_ROOT_DIR.$FTP_DIR."<br>";
     ftp_pwd($conn_id);
     ftp_mkdir($conn_id,$FTP_DIR);
     ftp_chdir($conn_id,$FTP_DIR); 
     foreach($f as $files) {
 	    $from = fopen($LOCAL_SERVER_DIR.$files,"r");	 
 	    if(ftp_fput($conn_id, $files, $from, $mode)){
 		    $count +=1;
 		    print $files."<br>";
 	    }
     }
     ftp_quit($conn_id);
 }
 print "upload : $count files.";
 ?>
 

</span></span>

yes those work i tried them

well i can’t them to work, i’m not really what i’m doing to get them to work, how do i implement them to html form code i have? sorry i’m new to php and don’t get to use it often.