Jump to content

Recommended Posts

hi does anyone tell me why this script does'n work? I use a post method in the html form.

 

<?php

$file = $_FILES['file'];

$ftpServer = "greengo.orgfree.com";

$ftpUser = "username";

$ftpPass = "+++++";

$post_dir= "upload/files/";

if($file)

echo "got data";

$conn = @ftp_connect($ftpServer) or die("Cannot initiate connection to host");

$login = @ftp_login($conn, $ftpUser, $ftpPass or die("Cannot login" );

 

$upload = @ftp_put($conn, $post_dir, $file, FTP_BINARY);

else

echo "haven't got data!!!";

if($upload)

echo "<table width='500' border='0'><tr><td><div align='center'><h2>File uploaded OK.</h2></div></td></tr><tr><td><div align='center'><a href='http://greengo.orgfree.com/upload'><h3>GO BACK<h3></a></div></td></tr></table>";

else

echo "<table width='500' border='0'><tr><td><div align='center'><h2>File upload failed.</h2></div></td></tr><tr><td><div align='center'><a href='http://greengo.orgfree.com/upload'><h3>GO BACK<h3></a></div></td></tr></table>";

 

ftp_quit($conn);

 

?>

Link to comment
https://forums.phpfreaks.com/topic/51066-php-ftp-upload/
Share on other sites

do you have permissions to run PHP on the server you are using?

 

Is PHP even on your server?

 

Did you upload the file before trying to reload the page (I do that alot and cant figure out why the change doesn't work)

 

Did you upload the file to the right directory? (see last statement)

 

Check the first 2, if those are ok, check the next 2.

 

If all 4 of these are good, then write this in notepad:

 

<?

phpinfo();

?>

 

save the file as phpinfo.php, then browse to the page - if you get something, PHP works, if not - your server is broke (or your not allowed to use PHP)

 

Link to comment
https://forums.phpfreaks.com/topic/51066-php-ftp-upload/#findComment-251353
Share on other sites

the form works I already tested it with another script on the server n I alredy did all those things yze

 

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>

<title>File sender</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<script language="JavaScript" type="text/javascript">

<!--

function checkform ( form )

{

 if (form.file.value == "")

 {

   alert( "Please enter a file." );

   form.file.focus();

   return false ;

 }

 return true ;

}

</script>

</head>

 

<body>

<form name="form1" enctype="multipart/form-data" method="post" action="ftp_php.php" onSubmit="return checkform(this);">

 <table width="500" border="0" align="center">

   <tr>

     <td><div align="center">

         <input name="file" type="file">

         <br>

       </div></td>

   </tr>

   <tr>

     <td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif">You

         can send one file at the time.<br>

         If you want to send more the one file at the time you can make a zip

         file and send it. </font></div></td>

   </tr>

   <tr>

     <td> <div align="center">

         <input type="submit" name="Submit" value="Send">

       </div></td>

   </tr>

 </table>

 <div align="center"></div>

</form>

</body>

</html>

 

Link to comment
https://forums.phpfreaks.com/topic/51066-php-ftp-upload/#findComment-251355
Share on other sites

Try this

 

<?php
$file = $_FILES['file'];
$ftpServer = "ggfdfgdf";
$ftpUser = "dfgdfgfdg";
$ftpPass = "dfgdfgdfgdf";
$post_dir= "upload/files/";
if($file)
{
	echo "got data";
	$conn = @ftp_connect($ftpServer) or die("Cannot initiate connection to host");
	$login = @ftp_login($conn, $ftpUser, $ftpPass) or die("Cannot login" );
	$upload = ftp_put($conn, $post_dir, $file, FTP_BINARY);
}else{
	echo "haven't got data!!!";
}
if($upload)
{
	echo "<table width='500' border='0'><tr><td><div align='center'><h2>File uploaded OK.</h2></div></td></tr><tr><td><div align='center'><a href='http://greengo.orgfree.com/upload'><h3>GO BACK<h3>[/a]</div></td></tr></table>";
}else{
	echo "<table width='500' border='0'><tr><td><div align='center'><h2>File upload failed.</h2></div></td></tr><tr><td><div align='center'><a href='http://greengo.orgfree.com/upload'><h3>GO BACK<h3>[/a]</div></td></tr></table>";
}
ftp_quit($conn);
?>

Link to comment
https://forums.phpfreaks.com/topic/51066-php-ftp-upload/#findComment-251369
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.