note 76729 added to function.ftp-put

From: Date: Sat, 28 Jul 2007 04:24:51 +0000
Subject: note 76729 added to function.ftp-put
Groups: php.notes 
Request: Send a blank email to php-notes+get-128997@lists.php.net to get a copy of this message
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 ---- Server IP: 202.67.10.139 Probable Submitter: 125.163.224.14 ---- Manual Page -- http://www.php.net/manual/en/function.ftp-put.php Edit -- https://master.php.net/note/edit/76729 Del: integrated -- https://master.php.net/note/delete/76729/integrated Del: useless -- https://master.php.net/note/delete/76729/useless Del: bad code -- https://master.php.net/note/delete/76729/bad+code Del: spam -- https://master.php.net/note/delete/76729/spam Del: non-english -- https://master.php.net/note/delete/76729/non-english Del: in docs -- https://master.php.net/note/delete/76729/in+docs Del: other reasons-- https://master.php.net/note/delete/76729 Reject -- https://master.php.net/note/reject/76729 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#128997) next »