Upload text file to Google uploads via PHP FTP PUT -


i trying upload text file created database via php.

the text file created ok, when try , upload file via php ftp put fails.

my code:

$filename = "products_admin.txt"; $handle = fopen($filename, 'w+'); fwrite($handle, $content); fclose($handle); echo "attempting connect <i>uploads.google.com</i>...<br />"; $ftp_connect = ftp_connect("uploads.google.com", "21", "5000") or die("failed connect."); $login_result = ftp_login($ftp_connect, "{usernamehere}", "{passwordhere}") or die("error: username or password incorrect.");  if((!$ftp_connect) || (!$login_result)) {     echo "error: couldn't connect <i>uploads.google.com</i>, upload failed.<br /><br />";     echo "<a href=\"javascript:location.reload(true)\">try again</a>";     exit; } else {     echo "connected <i>uploads.google.com</i>...<br />";     $upload = ftp_put($ftp_connect, $filename, $filename, ftp_ascii);     if(!$upload) {         echo "error: failed upload ".$filename." <i>uploads.google.com</i>.<br /><br />";         echo "<a href=\"javascript:location.reload(true)\">try again</a>";     } else {         echo "uploading <i>".$filename."</i> <i>froogle</i>...<br />";         echo "successfully uploaded <i>".$filename."</i> <i>uploads.google.com</i>.<br /><br />";         echo "done.";     } } ftp_close($ftp_connect); 

the error message

warning: ftp_put(): port ip not same 176.32.230.48. in /home/sites/mysite.co.uk/public_html/admin/controllers/generate_feed.php on line 100 error: failed upload products_admin.txt uploads.google.com.

you need activate passive mode:

... $login_result = ftp_login($ftp_connect, "{usernamehere}", "{passwordhere}") or die("error: username or password incorrect."); ftp_pasv($ftp_connect, true); ... 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -