EMAIL support@unlimited-space.com or CALL us on 1300 657 422



Domain Availability Search

ftp uploader, limit 100kb

Post your questions about PHP, MySQL, Perl, HTML, JavaScript coding and website design

ftp uploader, limit 100kb

Postby rschroers on Sat Jun 27, 2009 4:01 pm

Hello,
I have developed a php script on my site offering my customers the possibility to upload data via ftp.
I established an ftp account in cpanel, and created a login for customers on my website, who then are able after successful login to upload documents within a php session.
Through a html form (action="uploader.php") using <input type="file" ...> the uploader.php then uses $_FILES and ftp_put with connection details to upload the file.
It works for file sizes less then 100kb, anything over 100kb produces an error.

Could you please advise me whether there is any restriction from the server side?
Can that be solved or increased?

Thanks,
Regards,
Ralf
rschroers
 
Posts: 6
Joined: Sat Jun 27, 2009 3:45 pm

Re: ftp uploader, limit 100kb

Postby JustinS on Sun Jun 28, 2009 10:20 am

Hi Ralf,

I've responded directly to the ticket.

Regards,
Justin Scott | Customer Service | Unlimited-Space.com
http://www.unlimited-space.com | P: 1300 657 422 | F: 03 9532 1346
JustinS
 
Posts: 59
Joined: Sat Oct 11, 2008 8:07 am
Location: Melbourne

Re: ftp uploader, limit 100kb

Postby rschroers on Mon Jun 29, 2009 11:03 am

Hi there,

ok, the php settings server side shouldn't be a problem. But what is wrong with it then?

Ralf
rschroers
 
Posts: 6
Joined: Sat Jun 27, 2009 3:45 pm

Re: ftp uploader, limit 100kb

Postby Adam S on Mon Jun 29, 2009 11:59 am

Hi Ralf,

What is the error message?

Kind Regards,
Adam
Unlimited Space Customer Service | support@unlimited-Space.com
http://www.unlimited-space.com | P: 1300 657 422 | F: 03 9532 1346
Adam S
Site Admin
 
Posts: 156
Joined: Thu Oct 09, 2008 3:05 pm
Location: Melbourne

Re: ftp uploader, limit 100kb

Postby rschroers on Mon Jun 29, 2009 3:31 pm

Hi Adam,

here is the code for the 'uploader.php';
If files are larger than 100kb the $upload is false.

Regards,
Ralf


<?php session_start();

if ($_SESSION['sess_var'] == "ftp_session"){

$target_path = "client_ftp/";

$paths=$_POST['pathserver'];

$filep=$_FILES['uploadedfile']['tmp_name'];

$ftp_server= "ftp.xyz.com.au";

$ftp_user_name= "zyx.com.au";

$ftp_user_pass= "blah";

$name=$_FILES['uploadedfile']['name'];


// set up a connection to ftp server
$conn_id = ftp_connect($ftp_server);

// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

// check connection and login result
if ((!$conn_id) || (!$login_result)) {
echo "FTP connection has encountered an error!";
echo "Attempted to connect to $ftp_server for user $ftp_user_name....";
exit;
} else {
# echo "Connected to $ftp_server, for user $ftp_user_name".".....";
}

// upload the file to the path specified

switch($_FILES['uploadedfile']['type']) {
case "image/gif":
case "image/png":
case "image/jpeg":
case "image/bmp":
case "image/tif":

$upload = ftp_put($conn_id, $paths.'/'.$name, $filep, FTP_BINARY);
break;
default:
$upload = ftp_put($conn_id, $paths.'/'.$name, $filep, FTP_ASCII);
};

// check the upload status
if (!$upload) {
echo "FTP upload has encountered an error!";
} else {

echo "Uploaded file with name $name to $ftp_server ";
}

// close the FTP connection
ftp_close($conn_id);

}

else echo'</table><div style="padding-top:10px"><h3>Not Authorised.</h3></div>';

session_destroy();

?>
rschroers
 
Posts: 6
Joined: Sat Jun 27, 2009 3:45 pm

Re: ftp uploader, limit 100kb

Postby Lee G on Mon Jun 29, 2009 3:48 pm

Hi Ralf,

I'm a little confused as to what you are trying to do with the script. Are you trying to upload the files to an FTP account on our server, or another server?

Lee
Lee Gaywood | Company Director | Unlimited-Space.com
Quality Australian Web Hosting
Lee G
Site Admin
 
Posts: 255
Joined: Thu Oct 09, 2008 2:57 pm
Location: Melbourne

Re: ftp uploader, limit 100kb

Postby rschroers on Mon Jun 29, 2009 4:08 pm

Hi Lee,

I'm uploading data on your/unlimited-space server. I created an ftp account and a folder and clients/users should be able to upload data with the given username password.

As I mentioned in my first post, it works, but only small files less then 100 kb.

Regards,
Ralf
rschroers
 
Posts: 6
Joined: Sat Jun 27, 2009 3:45 pm

Re: ftp uploader, limit 100kb

Postby Lee G on Mon Jun 29, 2009 4:24 pm

Hi Ralf,

I don't think you need to be using the FTP functions at all. When you post the file to the PHP script, it is uploaded to the server. You are then transferring it from the server, back to the server via FTP.

Here's a great guide to PHP file uploads: http://www.tizag.com/phpT/fileupload.php

While this doesn't explain the strange issue with the file size, removing the FTP part of the script might just fix it.

Lee
Lee Gaywood | Company Director | Unlimited-Space.com
Quality Australian Web Hosting
Lee G
Site Admin
 
Posts: 255
Joined: Thu Oct 09, 2008 2:57 pm
Location: Melbourne

Re: ftp uploader, limit 100kb

Postby rschroers on Mon Jun 29, 2009 5:06 pm

Hi Lee,

thanks for replying.

I saw that link and tried this before. However, one reason I did not use it that way, was that the permissions of the server folder have to be set to public read/write (77x, or similar)..

That's why I'm opening a certain, predefined ftp connection with username/password that points only to a specific folder.

Have to keep trying, I guess..

Regards,
Ralf
rschroers
 
Posts: 6
Joined: Sat Jun 27, 2009 3:45 pm

Re: ftp uploader, limit 100kb

Postby rschroers on Fri Jul 03, 2009 12:22 pm

Hi there,

found the error. In my upload form the MAX_FILE_SIZE Value was set to 100000, i.e. 100kb.

Works ok now.

Thanks,
Ralf
rschroers
 
Posts: 6
Joined: Sat Jun 27, 2009 3:45 pm


Return to Designers & Developers Lounge

Who is online

Users browsing this forum: No registered users and 0 guests

cron