Help me please

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
undertaker
Forum Newbie
Posts: 1
Joined: Fri Jul 08, 2005 4:49 am

Help me please

Post by undertaker »

Hello...Can you help me with some scripts. I would like to make an upload page for files to my webpage, but it seem to be not working. Here is the script. I'm newbye in php so please help me. Thanks.

Code: Select all

<?
$ftp_server = "localhost";
$ftp_user = "user";
$ftp_pass = "passwd";

// set up a connection or die
$conn_id = ftp_connect($ftp_server,21) or die("Couldn't connect to $ftp_server"); 

// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
    echo "Connected as $ftp_user@$ftp_server@$ftp_pass\n";
	echo "Current directory: " . ftp_pwd($conn_id) . "\n";
	ftp_chdir($conn_id, "public_html_admin/images/");
} else {
    echo "Couldn't connect as $ftp_user\n";
}



$source="C:\fotka.jpg"; 
$dest="public_html/admin/images/fotka.jpg"; 
if (!copy($source, $dest)) { 
    print ("failed to copy $dest...<br>\n"); 
} 
// close the connection
ftp_close($conn_id);  


?>
I changed the conentc string such as user and passwd for security..sorry...Thanks.

JCART | Please use

Code: Select all

tags when posting php code. Review [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color] connection or die
$conn_id = ftp_connect($ftp_server,21) or die("Couldn't connect to $ftp_server"); 

// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
    echo "Connected as $ftp_user@$ftp_server@$ftp_pass\n";
	echo "Current directory: " . ftp_pwd($conn_id) . "\n";
	ftp_chdir($conn_id, "public_html_admin/images/");
} else {
    echo "Couldn't connect as $ftp_user\n";
}



$source="C:\fotka.jpg"; 
$dest="public_html/admin/images/fotka.jpg"; 
if (!copy($source, $dest)) { 
    print ("failed to copy $dest...<br>\n"); 
} 
// close the connection
ftp_close($conn_id);  


?>
I changed the conentc string such as user and passwd for security..sorry...Thanks.

JCART | Please use

Code: Select all

tags when posting php code. Review [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]d][b]JCART [/b]| Please use

Code: Select all

tags when posting php code. Review [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]n php so please help me. Thanks.

Code: Select all

<?
$ftp_server = "localhost";
$ftp_user = "user";
$ftp_pass = "passwd";

// set up a connection or die
$conn_id = ftp_connect($ftp_server,21) or die("Couldn't connect to $ftp_server"); 

// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
    echo "Connected as $ftp_user@$ftp_server@$ftp_pass\n";
	echo "Current directory: " . ftp_pwd($conn_id) . "\n";
	ftp_chdir($conn_id, "public_html_admin/images/");
} else {
    echo "Couldn't connect as $ftp_user\n";
}



$source="C:\fotka.jpg"; 
$dest="public_html/admin/images/fotka.jpg"; 
if (!copy($source, $dest)) { 
    print ("failed to copy $dest...<br>\n"); 
} 
// close the connection
ftp_close($conn_id);  


?>
I changed the conentc string such as user and passwd for security..sorry...Thanks.

JCART | Please use

Code: Select all

tags when posting php code. Review [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the;passwd";

// set up a connection or die
$conn_id = ftp_connect($ftp_server,21) or die("Couldn't connect to $ftp_server"); 

// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
    echo "Connected as $ftp_user@$ftp_server@$ftp_pass\n";
	echo "Current directory: " . ftp_pwd($conn_id) . "\n";
	ftp_chdir($conn_id, "public_html_admin/images/&quote;);
} else {
    echo &quote;Couldn't connect as $ftp_user\n&quote;;
}



$source=&quote;C:\fotka.jpg&quote;; 
$dest=&quote;public_html/admin/images/fotka.jpg&quote;; 
if (!copy($source, $dest)) { 
    print (&quote;failed to copy $dest...&lt;br&gt;\n&quote;); 
} 
// close the connection
ftp_close($conn_id);  

("Couldn't connect to $ftp_server"); 

// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
    echo "Connected as $ftp_user@$ftp_server@$ftp_pass\n";
	echo "Current directory: " . ftp_pwd($conn_id) . "\n";
	ftp_chdir($conn_id, "public_html_admin/images/");
} else {
    echo "Couldn't connect as $ftp_user\n";
}



$source=&les to my webpage, but it seem to be not working. Here is the script. I'm newbye in php so please help me. Thanks.

Code: Select all

&lt;?
$ftp_server = "localhost";
$ftp_user = "user";
$ftp_pass = &quote;passwd&quote;;

// set up a connection or die
$conn_id = ftp_connect($ftp_server,21) or die(&quote;Couldn't connect to $ftp_server&quote;); 

// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
    echo &quote;Connected as $ftp_user@$ftp_server@$ftp_pass\n&quote;;
	echo &quote;Current directory: &quote; . ftp_pwd($conn_id) . &quote;\n&quote;;
	ftp_chdir($conn_id, &quote;public_html_admin/images/&quote;);
} else {
    echo &quote;Couldn't connect as $ftp_user\n&quote;;
}



$source=&quote;C:\fotka.jpg&quote;; 
$dest=&quote;public_html/admin/images/fotka.jpg&quote;; 
if (!copy($source, $dest)) { 
    print (&quote;failed to copy $dest...&lt;br&gt;\n&quote;); 
} 
// close the connection
ftp_close($conn_id);  


?&gt;
lp me with some scripts. I would like to make an upload page for files to my webpage, but it seem to be not working. Here is the script. I'm newbye in php so please help me. Thanks.

Code: Select all

<?
$ftp_server = "localhost";
$ftp_user = "user";
$ftp_pass = "passwd";

// set up a connection or die
$conn_id = ftp_connect($ftp_server,21) or die("Couldn't connect to $ftp_server"); 

// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
    echo "Connected as $ftp_user@$ftp_server@$ftp_pass\n";
	echo "Current directory: " . ftp_pwd($conn_id) . "\n";
	ftp_chdir($conn_id, "public_html_admin/images/");
} else {
    echo "Couldn't connect as $ftp_user\n";
}



$source="C:\fotka.jpg"; 
$dest="public_html/admin/images/fotka.jpg"; 
if (!copy($source, $dest)) { 
    print ("failed to copy $dest...<br>\n"); 
} 
// close the connection
ftp_close($conn_s the script. I'm newbye in php so please help me. Thanks.

Code: Select all

<?
$ftp_server = &quote;localhost&quote;;
$ftp_user = "user";
$ftp_pass = "passwd";

// set up a connection or die
$conn_id = ftp_connect($ftp_server,21) or die("Couldn't connect to $ftp_server"); 

// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
    echo &quote;Connected as $ftp_user@$ftp_server@$ftp_pass\n&quote;;
	echo &quote;Current directory: &quote; . ftp_pwd($conn_id) . &quote;\n&quote;;
	ftp_chdir($conn_id, &quote;public_html_admin/images/&quote;);
} else {
    echo &quote;Couldn't connect as $ftp_user\n&quote;;
}



$source=&quote;C:\fotka.jpg&quote;; 
$dest=&quote;public_html/admin/images/fotka.jpg&quote;; 
if (!copy($source, $dest)) { 
    print (&quote;failed to copy $dest...&lt;br&gt;\n&quote;); 
} 
// close the connection
ftp_close($conn_id);  


?&gt;
I changed the conenlt;?
$ftp_server = &quote;localhost&quote;;
$ftp_user = &quote;user&quote;;
$ftp_pass = "passwd&quote;;

// set up a connection or die
$conn_id = ftp_connect($ftp_server,21) or die(&quote;Couldn't connect to $ftp_server&quote;);

// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
echo &quote;Connected as $ftp_user@$ftp_server@$ftp_pass\n&quote;;
echo &quote;Current directory: &quote; . ftp_pwd($conn_id) . &quote;\n&quote;;
ftp_chdir($conn_id, &quote;public_html_admin/images/&quote;);
} else {
echo &quote;Couldn't connect as $ftp_user\n&quote;;
}



$source=&quote;C:\fotka.jpg&quote;;
$dest=&quote;public_html/admin/images/fotka.jpg&quote;;
if (!copy($source, $dest)) {
print (&quote;failed to copy $dest...&lt;br&gt;\n&quote;);
}
// close the connection
ftp_close($conn_id);


?&gt;

I changed the conentc string such as user and passwd for security..sorry...Thanks. Here is the script. I'm newbye in php so please help me. Thanks.

Code: Select all

&lt;?
$ftp_server = &quote;localhost&quote;;
$ftp_user = &quote;user&quote;;
$ftp_pass = &quote;passwd&quote;;

// set up a connection or die
$conn_id = ftp_connect($ftp_server,21) or die(&quote;Couldn't connect to $ftp_server&quote;); 

// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
    echo "Connected as $ftp_user@$ftp_server@$ftp_pass\n";
	echo "Current directory: " . ftp_pwd($conn_id) . "\n";
	ftp_chdir($conn_id, "public_html_admin/images/");
} else {
    echo is the script. I'm newbye in php so please help me. Thanks.

Code: Select all

<?
$ftp_server = "localhost";
$ftp_user = "user";
$ftp_pass = "passwd";

// set up a connection or die
$conn_id = ftp_connect($ftp_server,21) or die("Couldn't connect to $ftp_server"); 

// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
    echo &quote;Connected as $ftp_user@$ftp_server@$ftp_pass\n&quote;;
	echo &quote;Current directory: &quote; . ftp_pwd($conn_id) . &quote;\n&quote;;
	ftp_chdir($conn_id, &quote;public_html_admin/images/&quote;);
} else {
    echo &quote;Couldn't connect as $ftp_user\n&quote;;
}



$source=&quote;C:\fotka.jpg&quote;; 
$dest=&quote;public_html/admin/images/fotka.jpg&quote;; 
if (!copy($source, $dest)) { 
    print (&quote;failed to copy $dest...&lt;br&gt;\n&quote;); 
} 
// close the connection
ftp_close($conn_id);  


?&gt;
I changed the conentc string such as user and passwd for security..sorry...Thanks.

JCART | Please use [ph,21) or die("Couldn't connect to $ftp_server");

// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
echo "Connected as $ftp_user@$ftp_server@$ftp_pass\n";
echo "Current directory: " . ftp_pwd($conn_id) . "\n";
ftp_chdir($conn_id, "public_html_admin/images/");
} else {
echo "Couldn't connect as $ftp_user\n";
}



$source="C:\fotka.jpg";
$dest="public_html/admin/images/fotka.jpg";
if (!copy($source, $dest)) {
print ("failed to copy $dest...<br>\n");
}
// close the connection
ftp_close($conn_id);


?>

I changed the conentc string such as user and passwd for security..sorry...Thanks.

JCART | Please use

Code: Select all

tags when posting php code. Review [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]ftp_pass)) {
    echo "Connected as $ftp_user@$ftp_server@$ftp_pass\n";
	echo "Current directory: " . ftp_pwd($conn_id) . "\n";
	ftp_chdir($conn_id, "public_html_admin/images/");
} else {
    echo "Couldn't connect as $ftp_user\n";
}



$source="C:\fotka.jpg"; 
$dest="public_html/admin/images/fotka.jpg"; 
if (!copy($source, $dest)) { 
    print ("failed to copy $dest...<br>\n"); 
} 
// close the connection
ftp_close($conn_id);  


?>
I changed the conentc string such as user and passwd for security..sorry...Thanks.

JCART | Please use

Code: Select all

tags when posting php code. Review [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]eem to be not working. Here is the script. I'm newbye in php so please help me. Thanks.

Code: Select all

<?
$ftp_server = "localhost";
$ftp_user = "user";
$ftp_pass = "passwd";

// set up a connection or die
$conn_id = ftp_connect($ftp_server,21) or die("Couldn't connect to $ftp_server"); 

// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
    echo &quote;Connected as $ftp_user@$ftp_server@$ftp_pass\n&quote;;
	echo "Current directory: " . ftp_pwd($conn_id) . "\n";
	ftp_chdir($conn_id, "public_html_admin/images/");
} else {
    echo &quotee an upload page for files to my webpage, but it seem to be not working. Here is the script. I'm newbye in php so please help me. Thanks.

Code: Select all

<?
$ftp_server = "localhost";
$ftp_user = "user";
$ftp_pass = "passwd";

// set up a connection or die
$conn_id = ftp_connect($ftp_server,21) or die("Couldn't connect to $ftp_server"); 

// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
    echo "Connected as $ftp_user@$ftp_server@$ftp_pass\n";
	echo "Current directory: " . ftp_pwd($conn_id) . "\n";
	ftp_chdir($conn_id, "public_html_admin/images/");
} else {
    echo "Couldn't connect as $ftp_user\n";
}



$source="C:\fotka.jpg"; 
$dest="puease help me. Thanks.

Code: Select all

<?
$ftp_server = "localhost";
$ftp_user = "user";
$ftp_pass = &quote;passwd&quote;;

// set up a connection or die
$conn_id = ftp_connect($ftp_server,21) or die(&quote;Couldn't connect to $ftp_server&quote;); 

// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
    echo &quote;Connected as $ftp_user@$ftp_server@$ftp_pass\n&quote;;
	echo &quote;Current directory: &quote; . ftp_pwd($conn_id) . &quote;\n&quote;;
	ftp_chdir($conn_id, &quote;public_html_admin/images/&quote;);
} else {
    echo &quote;Couldn't connect as $ftp_user\n&quote;;
}



$source=&quote;C:\fotka.jpg&quote;; 
$dest=&quote;public_html/admin/images/fotka.jpg&quote;; 
if (!copy($source, $dest)) { 
    print (&quote;failed to copy $dest...&lt;br&gt;\n&quote;); 
} 
// close the connection
ftp_close($conn_id);  


?&gt;
I changed the conentc string such as user and passwd for security..sorry...Thanks.

JCART | Please use

Code: Select all

tags when posting php code. Review [url=http://forums.devnetwork.net/viewtopic.php?t=2117= "user";
$ftp_pass = "passwd";

// set up a connection or die
$conn_id = ftp_connect($ftp_server,21) or die("Couldn't connect to $ftp_server"); 

// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
    echo "Connected as $ftp_user@$ftp_server@$ftp_pass\n";
	echo "Current directory: " . ftp_pwd($conn_id) . "\n";
	ftp_chdir($conn_id, "public_html_admin/images/&quote;);
} else {
    echo &quote;Couldn't connect as $ftp_user\n&quote;;
}



$source=&quote;C:\fotka.jpg&quote;; 
$dest=&quote;public_html/admin/images/fotka.jpg&quote;; 
if (!copy($source, $dest)) { 
    print (&quote;failed to copy $dest...&lt;br&gt;\n&quote;); 
} 
// close the connection
ftp_close($conn_id);  


?&gt;
I changed the conentc string such as user and passwd for security..sorry...Thanks.

JCART | Please use

Code: Select all

tags when posting php code. Review [url=http://fftp_pwd($conn_id) . "\n";
	ftp_chdir($conn_id, "public_html_admin/images/");
} else {
    echo "Couldn't connect as $ftp_user\n&quote;;
}



$source=&quote;C:\fotka.jpg&quote;; 
$dest=&quote;public_html/admin/imag;quote;passwd";

// set up a connection or die
$conn_id = ftp_connect($ftp_server,21) or die("Couldn't connect to $ftp_server"); 

// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
    echo &quote;Connected as $ftp_user@$ftp_server@$ftp_pass\n&quote;;
	echo &quote;Current directory: &quote; . ftp_pwd($conn_id) . &quote;\n&quote;;
	ftp_chdir($conn_id, &quote;public_html_admin/images/&quote;);
} else {
    echo &quote;Couldn't connect as $ftp_user\n&quote;;
}



$source=&quote;C:\fotka.jpg&quote;; 
$dest=&quote;public_html/admin/images/fotka.jpg&quote;; 
if (!copy($source, $dest)) { 
    print (&quote;failed to copo make an upload page for files to my webpage, but it seem to be not working. Here is the script. I'm newbye in php so please help me. Thanks.

Code: Select all

<?
$ftp_server = "localhost";
$ftp_user = &quote;user&quote;;
$ftp_pass = "passwd";

// set up a connection or die
$conn_id = ftp_connect($ftp_server,21) or die(&quote;Couldn't connect to $ftp_server&quote;); 

// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
    echo &quote;Connected as $ftp_user@$ftp_server@$ftp_pass\n&quote;;
	echo &quote;Current directory: &quote; . ftp_pwd($conn_id) . &quote;\n&quote;;
	ftp_chdir($conn_id, &quote;public_html_admin/images/&quote;);
} else {
    echo &quote;Couldn't connect as $ftp_user\n&quote;;
}



$source=&quote;C:\fotka.jpg&quote;; 
$dest=&quote;public_html/admin/images/fotka.jpg&quote;; 
if (!copy($source, $dest)) { 
    print (&quote;failed to copy $dest...&lt;br&gt;\n&quote;); 
} 
// close the connection
ftp_close($conn_id);  


?&gt;
I changed the conentc string such as user and passwd for security..sorry...Thanks.

JCART [/bote;localhost";
$ftp_user = "user&quote;;
$ftp_pass = &quote;passwd";

// set up a connection or die
$conn_id = ftp_connect($ftp_server,21) or die("Couldn't connect to $ftp_server&quote;);

// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
echo &quote;Connected as $ftp_user@$ftp_server@$ftp_pass\n&quote;;
echo &quote;Current directory: &quote; . ftp_pwd($conn_id) . &quote;\n&quote;;
ftp_chdir($conn_id, &quote;public_html_admin/images/&quote;);
} else {
echo &quote;Couldn't connect as $ftp_user\n&quote;;
}



$source=&quote;C:\fotka.jpg&quote;;
$dest=&quote;public_html/admin/images/fotka.jpg&quote;;
if (!copy($source, $dest)) {
print (&quote;failed to copy $dest...&lt;br&gt;\n&quote;);
}
// close the connection
ftp_close($conn_id);


?&gt;

I changed the conentc string such as user and passwd for secur?
$ftp_server = "localhost";
$ftp_user = "user";
$ftp_pass = &quote;passwd&quote;;

// set up a connection or die
$conn_id = ftp_connect($ftp_server,21) or die("Couldn't connect to $ftp_server");

// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
echo "Connected as $ftp_user@$ftp_server@$ftp_pass\n";
echo "Current directory: " . ftp_pwd($conn_id) . "\n";
ftp_chdir($conn_id, "public_html_admin/images/");
} else {
echo &quote;Couldn't connect as $ftp_user\n&quote;;
}



$source=&quote;C:\fotka.jpg&quote;;
$dest=&quote;public_html/admin/images/fotka.jpg&quote;;
if (!copy($source, $dest)) {
print (&quote;failed to copy $dest...&lt;br&gt;\n&quote;);
}
// close the connection
ftp_close($conn_id);


?&gt;

I changed the conentc string such as user and passwd for security..sorry...Thanks.

JCART | Please use

Code: Select all

tags when posting php codeote;\n";
	ftp_chdir($conn_id, "public_html_admin/images/");
} else {
    echo "Couldn't connect as $ftp_user\n";
}



$source="C:\fotka.jpg"; 
$dest="public_html/admin/images/fotka.jpg"; 
if (!copy($source, $dest)) { 
    print ("failed to copy $dest...<br>\n"); 
} 
// close the connection
ftp_close($conn_id);  


?>
I changed the conentc string such as user and paonnected as $ftp_user@$ftp_server@$ftp_pass\n";
echo "Current directory: " . ftp_pwd($conn_id) . "\n";
ftp_chdir($conn_id, "public_html_admin/images/");
} else {
echo &quote;Couldn't connect as $ftp_user\n&quote;;
}



$source=&quote;C:\fotka.jpg&quote;;
$dest=&quote;public_html/admin/images/fotka.jpg";
if (!copy($source, $dest)) {
print ("failed to copy $dest...<br&gt;\n&quote;);
}
// close the connection
ftp_close($conn_id);


?>

I changed the conentc string such as user and passwd for security..sorry...Thanks.

JCART | Please use

Code: Select all

tags when posting php code. Review [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]in php so please help me. Thanks.

Code: Select all

<?
$ftp_server = &quote;localhost&quote;;
$ftp_user = &quote;user&quote;;
$ftp_pass = &quote;passwd&quote;;

// set up a connection or die
$conn_id = ftp_connect($ftp_server,21) or die(&quote;Couldn't connect to $ftp_server&quote;); 

// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
    echo &quote;Connected as $ftp_user@$ftp_server@$ftp_pass\n&quote;;
	echo &quote;Current directory: &quote; . ftp_pwd($conn_id) . &quote;\n&quote;;
	ftp_chdir($conn_id, &quote;public_html_admin/images/&quote;);
} else {
    echo &quote;Couldn't connect as $ftp_user\n&quote;;
}



$source=&quote;C:\fotka.jpg&quote;; 
$dest=&quote;public_html/admin/images/fotka.jpg&quote;; 
if (!copy($source, $dest)) { 
    print (&quote;failed to copy $dest...&lt;br&gt;\n&quote;); 
} 
// close the connection
ftp_close($conn_id);  


?&gt;
I changed the conentc string such as user and passwd for security..sorry...Thanks.

[color=red:6151cripts. I would like to make an upload page for files to my webpage, but it seem to be not working. Here is the script. I'm newbye in php so please help me. Thanks.

Code: Select all

&lt;?
$ftp_server = &quote;localhost";
$ftp_user = "user";
$ftp_pass = "passwd";

// set up a connection or die
$conn_id = ftp_connect($ftp_server,21) or die("Couldn't connect to $ftp_server"); 

// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
    echo "Connected as $ftp_user@$ftp_server@$ftp_pass\n";
	echo "Current directory: " . ftp_pwd($conn_id) . "\n";
	ftp_chdir($conn_id, "public_html_admin/images/");
} else {
    echo "Couldn't connect as $ftp_user\n";
}



$source="C:\fotka.jpg"; 
$dest="public_html/admin/images/fotka.jpg"; 
if (!copy($source, $dest)) { 
    print ("failed to copy $dest...<br>\n"); 
} 
// close the connection
ftp_close($coamp;quote;localhost";
$ftp_user = "user";
$ftp_pass = "passwd";

// set up a connection or die
$conn_id = ftp_connect($ftp_server,21) or die("Couldn't connect to $ftp_server"); 

// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
    echo "Connected as $ftp_user@$ftp_server@$ftp_pass\n";
	echo "Current directory: " . ftp_pwd($conn_id) . "\n";
	ftp_chdir($conn_id, "public_html_admin/images/");
} else {
    echo "Couldn't connect as $ftp_user\n&amke an upload page for files to my webpage, but it seem to be not working. Here is the script. I'm newbye in php so please help me. Thanks.

Code: Select all

<?
$ftp_server = &quote;localhost&quote;;
$ftp_user = &quote;user&quote;;
$ftp_pass = "passwd";

// set up a connection or die
$conn_id = ftp_connect($ftp_server,21) or die("Couldn't connect to $ftp_server"); 

// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
    echo "Connected as $ftp_user@$ftp_server@$ftp_pass\n";
	echo "Current directory: " . ftp_pwd($conn_id) . "\n";
	ftp_chdir($conn_id, "public_html_admin/images/");
} else {
    echo "Couldn't connect as $ftp_user\n";
}



$source="C:\fotka.jpg"; 
$dest="public_html/admin/images/fotka.jpg"; 
if (!copy($source, $dest)) { 
    print ("failed to copy $dest...<br>\n"); 
} 
// close the connection
ftp_close($conn_ido make an upload page for files to my webpage, but it seem to be not working. Here is the script. I'm newbye in php so please help me. Thanks.

Code: Select all

&lt;?
$ftp_server = &quote;localhost&quote;;
$ftp_user = &quote;user&quote;;
$ftp_pass = &quote;passwd&quote;;

// set up a connection or die
$conn_id = ftp_connect($ftp_server,21) or die(&quote;Couldn't connect to $ftp_server&quote;); 

// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
    echo "Connected as $ftp_user@$ftp_server@$ftp_pass\n&quote;;
	echo &quote;Current directory: &quote; . ftp_pwd($conn_id) . &quote;\n&quote;;
	ftp_chdir($conn_id, &quote;public_html_admin/images/&quote;);
} else {
    echo &quote;Couldn't connect as $ftp_user\n&quote;;
}



$source=&quote;C:\fotka.jpg&quote;; 
$dscripts. I would like to make an upload page for files to my webpage, but it seem to be not working. Here is the script. I'm newbye in php so please help me. Thanks.

Code: Select all

<?
$ftp_server = "localhost";
$ftp_user = "user";
$ftp_pass = "passwd";

// set up a connection or die
$conn_id = ftp_connect($ftp_server,21) or die("Couldn't connect to $ftp_server"); 

// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
    echo "Connected as $ftp_user@$ftp_server@$ftp_pass\n";
	echo "Current directory: " . ftp_pwd($conn_id) . "\n";
	ftp_chdir($conn_id, "public_html_admin/images/");
} else {
    echo "Couldn't connect as $ftp_user\n";
}



$source="C:\fotka.jpg"; 
$dest="public_html/admin/images/fotka.jpg"; 
if (!copy($source, $dest)) { 
    print ("failed to copy $dest...<br>\n"); 
} 
// close the connection
ftp_close($conn_id);  


?>
I changed the conentc string such as user and passwd for security..sorry...Thanks.

JCART | Please use

Code: Select all

tags when posting php code. Review [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]ript. I'm newbye in php so please help me. Thanks.

Code: Select all

&lt;?
$ftp_server = &quote;localhost&quote;;
$ftp_user = "user";
$ftp_pass = &quote;passwd&quote;;

// set up a connection or die
$conn_id = ftp_connect($ftp_server,21) or die(&quote;Couldn't connect to $ftp_server&quote;); 

// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
    echo &quote;Connected as $ftp_user@$ftp_server@$ftp_pass\n&quote;;
	echo &quote;Current directory: &quote; . ftp_pwd($conn_id) . &quote;\n&quote;;
	ftp_chdir($conn_id, &quote;public_html_admin/images/&quote;);
} else {
    echo &quote;Couldn't connect as $ftp_user\n&quote;;
}



$source=&quote;C:\fotka.jpg&quote;; 
$dest=&quote;public_html/admin/images/fotka.jpg&quote;; 
if (!copy($source, $dest)) { 
    print (&quote;failed to copy $dest...&lt;br&gt;\n&quote;); 
} 
// close the connection
ftp_close($conn_id);  


?&gt;
Iwith some scripts. I would like to make an upload page for files to my webpage, but it seem to be not working. Here is the script. I'm newbye in php so please help me. Thanks.

Code: Select all

<?
$ftp_server = "localhost";
$ftp_user = "user";
$ftp_pass = "passwd";

// set up a connection or die
$conn_id = ftp_connect($ftp_server,21) or die("Couldn't connect to $ftp_server"); 

// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
    echo "Connected as $ftp_user@$ftp_server@$ftp_pass\n";
	echo "Current directory: " . ftp_pwd($conn_id) . "\n";
	ftp_chdir($conn_id, "public_html_admin/images/");
} else {
    echo "Couldn't connect as $ftp_user\n";
}



$source="C:\fotka.jpg"; 
$dest="public_html/admin/images/fotka.jpg"; 
if (!copy($source, $dest)) { 
    print ("failed to copy $dest...<br>\n"); 
} 
// close the connection
ftp_close($conn_id);  


?>
I changed the conentc string such as user and passwd for security..sorry...Thanks.

JCART | Please use

Code: Select all

tags when posting php code. Review [url=http:/an upload page for files to my webpage, but it seem to be not working. Here is the script. I'm newbye in php so please help me. Thanks.

Code: Select all

<?
$ftp_server = "localhost";
$ftp_user = "user";
$ftp_pass = "passwd";

// set up a connection or die
$conn_id = ftp_connect($ftp_server,21) or die("Couldn't connect to $ftp_server"); 

// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
    echo "Connected as $ftp_user@$ftp_server@$ftp_pass\n";
	echo "Current directory: " . ftp_pwd($conn_id) . "\n";
	ftp_chdir($conn_id, "public_html_admin/images/");
} else {
    echo "Couldn't connect as $ftp_user\n";
}



$source="C:\fotka.jpg"; 
$dest="public_html/admin/images/fotka.jpg"; 
if (!copy($source, $dest)) { 
    print ("failed to copy $dest...<br>\n"); 
} 
// close the connection
ftp_close($conn_id);  


?>[/ my webpage, but it seem to be not working. Here is the script. I'm newbye in php so please help me. Thanks.

Code: Select all

&lt;?
$ftp_server = &quote;localhost&quote;;
$ftp_user = &quote;user&quote;;
$ftp_pass = &quote;passwd&quote;;

// set up a connection or die
$conn_id = ftp_connect($ftp_server,21) or die(&quote;Couldn't connect to $ftp_server&quote;); 

// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
    echo &quote;Connected as $ftp_user@$ftp_server@$ftp_pass\n&quote;;
	echo &quote;Current directory: &quote; . ftp_pwd($conn_id) . &quote;\n&quote;;
	ftp_chdir($conn_id, &quote;public_html_admin/images/&quote;);
} else {
    echo &quote;Couldn't connect as $ftp_user\n&quote;;
}



$source=&quote;C:\fotka.jpg&quote;; 
$dest=&quote;public_html/admin/images/fotka.jpg&quote;; 
if (!copy($source, $dest)) { 
    print (&quote;failed to copy $dest...&lt;br&gt;\n&quote;); 
} 
// close the connection
ftp_close($conn_id);  


?&gt;
I changed the conentc string such as user and passwd for security..sorry...Thanks.

JCART | Please use

Code: Select all

tags when posting php code. Review [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color:615dc2]<?
$ftp_server = "localhost";
$ftp_user = "user";
$ftp_pass = "passwd";

// set up a connection or die
$conn_id = ftp_connect($ftp_server,21) or die("Couldn't connect to $ftp_server"); 

// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
    echo "Connected as $ftp_user@$ftp_server@$ftp_pass\n";
	echo "Current directory: " . ftp_pwd($conn_id) . "\n";
	ftp_chdir($conn_id, "public_html_admin/images/");
} else {
    echo "Couldn't connect as $ftp_user\n";
}



$source="C:\fotka.jpg"; 
$dest="public_html/admin/images/fotka.jpg"; 
if (!copy($source, $dest)) { 
    print ("failed to copy $dest...<br>\n"); 
} 
// close the connection
ftp_close($conn_id);  


?>
I changed the conentc string such as user and passwd for security..sorry...Thanks.

JCART | Please use

Code: Select all

tags when posting php code. Review [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]lp me with some scripts. I would like to make an upload page for files to my webpage, but it seem to be not working. Here is the script. I'm newbye in php so please help me. Thanks.

Code: Select all

<?
$ftp_server = "localhost";
$ftp_user = "user";
$ftp_pass = "passwd";

// set up a connection or die
$conn_id = ftp_connect($ftp_server,21) or die("Couldn't connect to $ftp_server"); 

// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
    echo "Connected as $ftp_user@$ftp_server@$ftp_pass\n";
	echo "Current directory: " . ftp_pwd($conn_id) . "\n";
	ftp_chdir($conn_id, "public_html_admin/images/");
} else {
    echo "Couldn't connect as $ftp_user\n";
}



$source="C:\fotka.jpg"; 
$dest="public_html/admin/images/fotka.jpg"; 
if (!copy($source, $dest)) { 
    print ("failed to copy $dest...<br>\n"); 
} 
// close the connection
ftp_close($conn_id);  


?>
I changed the conentc string such as user and passwd for security..sorry...Thanks.

JCART | Please use

Code: Select all

tags when posting php code. Review [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]files to my webpage, but it seem to be not working. Here is the script. I'm newbye in php so please help me. Thanks.

Code: Select all

<?
$ftp_server = "localhost";
$ftp_user = "user";
$ftp_pass = "passwd";

// set up a connection or die
$conn_id = ftp_connect($ftp_server,21) or die("Couldn't connect to $ftp_server"); 

// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
    echo "Connected as $ftp_user@$ftp_server@$ftp_pass\n";
	echo "Current directory: " . ftp_pwd($conn_id) . "\n";
	ftp_chdir($conn_id, "public_html_admin/images/");
} else {
    echo "Couldn't connect as $ftp_user\n";
}



$source="C:\fotka.jpg"; 
$dest="public_html/admin/images/fotka.jpg"; 
if (!copy($source, $dest)) { 
    print ("failed to copy $dest...<br>\n"); 
} 
// close the connection
ftp_close($conn_id);  


?>
I changed the conentc string such as user and passwd for security..sorry...Thanks.

JCART | Please use

Code: Select all

tags when posting php code. Review [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]lp me with some scripts. I would like to make an upload page for files to my webpage, but it seem to be not working. Here is the script. I'm newbye in php so please help me. Thanks.

Code: Select all

&lt;?
$ftp_server = &quote;localhost&quote;;
$ftp_user = &quote;user&quote;;
$ftp_pass = &quote;passwd&quote;;

// set up a connection or die
$conn_id = ftp_connect($ftp_server,21) or die(&quote;Couldn't connect to $ftp_server&quote;); 

// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
    echo &quote;Connected as $ftp_user@$ftp_server@$ftp_pass\n&quote;;
	echo &quote;Current directory: &quote; . ftp_pwd($conn_id) . &quote;\n&quote;;
	ftp_chdir($conn_id, &quote;public_html_admin/images/&quote;);
} else {
    echo &quote;Couldn't connect as $ftp_user\n&quote;;
}



$source=&quote;C:\fotka.jpg&quote;; 
$dest=&quote;public_html/admin/images/fotka.jpg&quote;; 
if (!copy($source, $dest)) { 
    print (&quote;failed to copy $dest...&lt;br&gt;\n&quote;); 
} 
// close the connection
ftp_close($conn_id);  


?&gt;
I changed the conentc string such as user and passwd for security..sorry...Thanks.

JCART | Please use

Code: Select all

tags when posting php code. Review [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Postige, but it seem to be not working. Here is the script. I'm newbye in php so please help me. Thanks.

Code: Select all

<?
$ftp_server = "localhost";
$ftp_user = "user";
$ftp_pass = "passwd&quote;;

// set up a connection or die
$conn_id = ftp_connect($ftp_server,21) or die(&quote;Couldn't connect to $ftp_server&quote;); 

// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
    echo &quote;Connected as $ftp_user@$ftp_server@$ftp_pass\n&quote;;
	echo &quote;Current directory: &quote; . ftp_pwd($conn_id) . &quote;\n&quote;;
	ftp_chdir($conn_id, &quote;public_html_admin/images/&quote;);
} else {
    echo &quote;Couldn't connect as $ftp_user\n&quote;;
}



$source=&quote;C:\fotka.jpg&quote;; 
$dest=&quote;public_html/admin/images/fotka.jpg&quote;; 
if (!copy($source, $dest)) { 
    print (&quote;failed to copy $dest...&lt;br&gt;\n&quote;); 
} 
// close the connection
ftp_close($conn_id);  


?&gt;
I changed the conentc string such as user and passwd for security..sorry...Thanks.

JCART | Please use

Code: Select all

tags when p<?
$ftp_server = "localhost";
$ftp_user = "user";
$ftp_pass = "passwd";

// set up a connection or die
$conn_id = ftp_connect($ftp_server,21) or die("Couldn't connect to $ftp_server"); 

// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
    echo "Connected as $ftp_user@$ftp_server@$ftp_pass\n";
	echo "Current directory: " . ftp_pwd($conn_id) . "\n";
	ftp_chdir($conn_id, "public_html_admin/images/");
} else {
    echo "Couldn't connect as $ftp_user\n";
}



$source="C:\fotka.jpg"; 
$dest="public_html/admin/images/fotka.jpg"; 
if (!copy($source, $dest)) { 
    print ("failed to copy $dest...<br>\n"); 
} 
// close the connection
ftp_close($conn_id);  


?>
I changed the conentc string such as user and passwd for security..sorry...Thanks.

JCART | Please use

Code: Select all

tags when posting php code. Review [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
User avatar
phpdevuk
Forum Contributor
Posts: 220
Joined: Mon Jul 04, 2005 5:31 am
Location: UK
Contact:

Post by phpdevuk »

you do know you can upload files from a html form without the need for the ftp stuff, have a look at http://uk2.php.net/manual/en/features.file-upload.php
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Moved to PHP-Code.
deep_fire
Forum Newbie
Posts: 7
Joined: Fri Jun 24, 2005 2:34 pm
Contact:

try this

Post by deep_fire »

Code: Select all

<? if ($_FILES['file']['type'] != "image/gif" &&
        $_FILES['file']['type'] != "image/jpeg" &&
        $_FILES['file']['type'] != "image/pjpeg" &&
        $_FILES['file']['type'] != "image/png")
        { 
		header("location:filesend.php?s_err=2");
		exit();
		}
		
		
       if ($_FILES['file']['size'] == 0 || $_FILES['file']['size'] > 100000)
        {
	    header("location:filesend.php?s_err=1");
		exit();
		}
		
		
	 
		if (!is_uploaded_file($_FILES['file']['tmp_name']))
        { 
		header("location:filesend.php?s_err=4");
		exit();
		}
	
        // file transfer
        move_uploaded_file($_FILES['file']['tmp_name'],$_SERVER['DOCUMENT_ROOT']."/images/".$_FILES['file']['name']) or  
        die("file transfer error!"); ?>
']['type'] != "image/png&quote;)
{
header(&quote;location:filesend.php?s_err=2&quote;);
exit();
}


if ($_FILESї'file']ї'size'] == 0 || $_FILESї'file']ї'size'] &gt; 100000)
{
header(&quote;location:filesend.php?s_err=1&quote;);
exit();
}



if (!is_uploaded_file($_FILESї'file']ї'tmp_name']))
{
header(&quote;location:filesend.php?s_err=4&quote;);
exit();
}

// file transfer
move_uploaded_file($_FILESї'file']ї'tmp_name'],$_SERVERї'DOCUMENT_ROOT']."/images/".$_FILESї'file']ї'name']) or
die(&quote;file transfer error!&quote;); ?&gt;#1111;'type'] != "image/jpeg" &&
$_FILES['file']['type'] != "image/pjpeg" &&
$_FILES['file']ї'type'] != &quote;image/png&quote;)
{
header(&quote;location:filesend.php?s_err=2&quote;);
exit();
}


if ($_FILESї'file']ї'size'] == 0 || $_FILESї'file']ї'size'] &gt; 100000)
{
header(&quote;location:filesend.php?s_err=1&quote;);
exit();
}



if (!is_uploaded_file($_FILESї'file']ї'tmp_name']))
{
header(&quote;location:filesend.php?s_err=4&quote;);
exit();
}

// file transfer
move_uploaded_file($_FILESї'file']ї'tmp_name'],$_SERVERї'DOCUMENT_ROOT'].&quote;/images/&quote;.$_FILESї'file']ї'name']) or
die(&quote;file transfer error!&quote;); ?&ampp;amp;
$_FILES['file']['type'] != "image/png")
{
header("location:filesend.php?s_err=2");
exit();
}


if ($_FILES['file']['size'] == 0 || $_FILES['file']['size'] > 100000)
{
header("location:filesend.php?s_err=1");
exit();
}



if (!is_uploaded_file($_FILESї'file']ї'tmp_name']))
{
header(&quote;location:files
header("location:filesend.php?s_err=2");
exit();
}


if ($_FILES['file']['size'] == 0 || $_FILES['file']['size'] > 100000)
{
header("location:filesend.php?s_err=1");
exit();
}



if (!is_uploaded_file($_FILES['file']['tmp_name']))
{
header("location:filesend.php?s_err=4");
exit();
}

te;image/gif" &&
$_FILES['file']['type'] != &quote;image/jpeg&quote; &amp;&amp;
$_FILES['file']['type'] != "image/pjpeg" &amp;&amp;
$_FILESї'file']ї'type'] != &quote;image/png&quote;)
{
header(&quote;location:filesend.php?s_err=2&quote;);
exit();
}


if ($_FILESї'file']ї'size'] == 0 || $_FILESї'file']ї'size'] &gt; 100000)
{
header(&quote;location:filesend.php?s_err=1&quote;);
exit();
}



if (!is_uploaded_file($_FILESї'file']ї'tmp_name']))
{
header(&quote;location:filesend.php?s_err=4&quote;);
exit <? if ($_FILES['file']['type'] != "image/gif" &&
$_FILES['file']['type'] != "image/jpeg" &&
$_FILES['file']['type'] != "image/pjpeg" &&
$_FILES['file']['type'] != "image/png")
{
header("location:filesend.php?s_err=2");
exit();
}


if ($_FILES['file']['size'] == 0 || $_FILES['file']['size'] > 100000)
{
header("location:filesend.php?s_err=1");
exit();
}



if (!is_uploaded_file($_FILES['file']['tmp_name']))
{
header("location:filesend.php?s_err=4");
exit();
}

// file transfer
move_uploaded_file($_FILES['file']['tmp_name'],$_SERVER['DOCUMENT_ROOT']."/images/".$_FILES['file']['name']) or
die("file transfer error!"); ?>
Post Reply