note 76729 rejected from function.ftp-put by nlopess

From: Date: Sat, 24 Nov 2007 11:32:51 +0000
Subject: note 76729 rejected from function.ftp-put by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-132536@lists.php.net to get a copy of this message
Note Submitter: rpl oye at(@) gmail dot kom (com) ---- I'm on IIS, and using freeftpd 1.0 and i don't have accesss to php.ini, and in a shared hosting environment... the script is like this... ################# <div align="left"><pre><? set_time_limit(0); if($_POST['button']=="Submit"){ stripslashes($_POST['f_hidden']); $ftp_server = /*"localhost";*/"*****"; $remote_file = rand()."_".stripslashes( removebadstring( basename($_POST['f_hidden']))); // set up a connection or die $conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server"); $ftp_user_name=/*"newuser";*/"*****"; $ftp_user_pass=/*"wampp";//*/"*****"; $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); //ftp_pasv($conn_id, true); //you can comment or uncomment it if you using firewall // echo "ftp pasv is on"; echo "login result : ".$login_result."\n"; echo "local file ".$localfile."\n"; echo "remote file ".$remote_file."\n"; echo "Current directory is now: " . ftp_pwd($conn_id) . "\n"; // change directory if needed, if (ftp_chdir($conn_id, "files")) { echo "Current directory is now: " . ftp_pwd($conn_id) . "\n"; } else echo "can't change dir"; $contents = ftp_nlist($conn_id, "."); // output $contents print_r($contents); if (ftp_put( $conn_id, $remote_file, $localfile, FTP_BINARY )) { echo "successfully uploaded $file\n"; } else { echo "There was a problem while uploading $file\n"; } // close the connection ftp_close($conn_id); } function removebadstring($word){ //$string = "%,^,#,'"; $stringA = array("%5E","^","^^","#","'","%"); //for($i=0;$i<count($stringA);$i++){ $words = str_replace($stringA,"",$word); //} return $words; } ?></pre></div> // this js function will fill f_hidden form value with full path of a local file function changehidden(){ document.uploadForm.f_hidden.value=document.uploadForm.f.value; } </script> <div id="container"> <div id="sidebar1"> <h3>&nbsp;</h3> <!-- end #sidebar1 --></div> <div id="mainContent"> <h1> Main Content </h1> <form action="<?=$_SERVER['PHP_SELF']?>" enctype="application/x-www-form-urlencoded" method="post" name="uploadForm" id="uploadForm"> <input type="file" name="f" id="f" onChange="changehidden()" /> <input type="hidden" name="f_hidden" value="" /> <input type="submit" name="button" id="button" value="Submit" /> <input type="hidden" name="MAX_FILE_SIZE" value="1073741824" /> </form> ################# this script is working well on localhost ( in a local environment (apache 2, php 4.4 and filezilla ftp server)) but after i upload it in production environment (iis,php4.4, freeftpd 1.0) this script will produce "There was a problem while uploading" which is because of ftp_put command.. please help me, where the hell is wrong with ftp_put command , because in apache and filezilla ftpd is fine.. nb: i'm commenting pasv command because there is no time out error while executing this script

« previous php.notes (#132536) next »