Can i use php ftp?

No longer supported!

Moderator: Moderators

Postby tharix » Fri Jun 18, 2004 6:41 pm

Can I use php ftp (i mean the php ftp functions) to upload files??
My script should work.. but the error said he couln't connect while the login-data is correct...

oh, this script comes from a webpage that I'm building for somebody else...

the script:

if(!isset($upload)) {
$upload = "";
switch($upload) {
include "config.php";
<form name="file" method=POST action="ftpupload.php?upload=doupload" enctype="multipart/form-data">

<input type=hidden name=type value="">

<input type=file name=source_file size=20> <br>
<input type=submit name=btnSubmit value=Submit size=20></form>

case "doupload":

$conn_id = ftp_connect($ftp_server,791);

// login with username and password
$login_result = ftp_login($conn_id, $user, $passwd);

// check connection
if ((!$conn_id) || (!$login_result)) {
echo "FTP connection has failed!";
echo "Attempted to connect to $ftp_server for user $ftp_user_name";
} else {
echo "<br>Connected to $ftp_server, for user $user<br>";

//directorylike /


echo ("<br>");
print $destination_file;

echo ("<br>");

if($_FILES['file']['type']== "image/pjepg" || $_FILES['file']['type']== "image/gif"){
if($_FILES['file']['size']< "800000"){
// upload the file
$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);

// check upload status
if (!$upload) {
echo "FTP upload has failed!";
} else {
echo "Uploaded $source_file to $ftp_server as $destination_file";
De url die je kunt gebruiken om het plaatje te includen is:<br>
<em><img src='$destination_file'></em><br>
Het plaatje dat je uploade:<br>
<img src='$destination_file'><br><br>
<br><a href='Javascript: history.go(-1)'>Upload opnieuw een plaatje!</a><br>
print"Verkeerd type bestand! Ga terug met de knop terug/back!";
print"Het bestand is te groot! Ga terug met de knop terug/back!";
// close the FTP stream



PS Don't mention the dutch text... and my bad english

Postby DenisF » Fri Jun 18, 2004 11:35 pm

If it's inside the polarhome system, why bother with external hostnames and ports?

try for hostname, and plain ol' port 21 for ftp.
[ FAQ ] :: [ Policy ] :: [ Port Forwarding Guide ] :: [ Search ]
User avatar
Forum Admin
Forum Admin
Posts: 679
Joined: Mon Dec 16, 2002 9:09 pm
Location: Israhell

Return to FTP accounts

Who is online

Users browsing this forum: No registered users and 1 guest