FTP Upload - APPLICATION ERROR #503

Get help from other users here.

Moderators: Developer, Contributor

Post Reply
niquito12
Posts: 4
Joined: 09 Dec 2009, 08:54

FTP Upload - APPLICATION ERROR #503

Post by niquito12 »

Hi Community!

I am just trying to set up Mantis 1.1.8 with FTP upload.
If i try to upload a file (no matter what filesize) i get an error
APPLICATION ERROR #503
File Transfer wasn't successfull...

My settings in the config_inc.php are:

$g_allow_file_upload = ON;
$g_max_file_size= 10000000;
$g_file_upload_method = FTP;
$g_file_upload_ftp_server = 'serveradress.com';
$g_file_upload_ftp_user = 'acc';
$g_file_upload_ftp_pass = 'pwd';

The weird thing is, that I tried the ftp user pass server in my browser and i can upload files there. I would be very happy if you have any hints for me regarding this problem.

wkr niquito 12.
niquito12
Posts: 4
Joined: 09 Dec 2009, 08:54

Re: FTP Upload - APPLICATION ERROR #503

Post by niquito12 »

Fixed it by setting the file path in the projects relative to mantis root.
MantisNooby
Posts: 9
Joined: 05 Oct 2010, 20:11

Re: FTP Upload - APPLICATION ERROR #503

Post by MantisNooby »

I am getting the same error when trying to upload via FTP.

One copy of Mantis gets this error:

PHP Notice: Undefined offset: 0 in D:\Inetpub\WatMantis\Mantis\core\html_api.php on line 697
PHP Notice: Undefined offset: 2 in D:\Inetpub\WatMantis\Mantis\core\html_api.php on line 698
PHP Notice: Undefined offset: 0 in D:\Inetpub\WatMantis\Mantis\core\html_api.php on line 697
PHP Notice: Undefined offset: 2 in D:\Inetpub\WatMantis\Mantis\core\html_api.php on line 698


The other local copy of Mantis gets this error:

APPLICATION ERROR #503

Invalid upload path. Directory either does not exist or not writable to webserver.


The folder has the right access, I can access it in a browser and I can log in successfully using a FTP client.

When trying to update the Upload File Path in manage projects to the folder location, I get the same 4 lines above as an error.

My config_inc.php file is as follows:

$g_file_upload_method = FTP;
$g_file_upload_ftp_server = 'mantis.myserver.com';
$g_file_upload_ftp_user = 'user';
$g_file_upload_ftp_pass = 'pass';
$g_absolute_path_default_upload_folder = 'ftpfolderdirectory';

The php.ini settings are also set to allow upload files etc.

When the $g_file_upload_method is set to DATABASE, files are uploaded fine.

My Mantis version is 1.2.3, PHP is 5.3.0 and I am using an IIS server.

I'd appreciate any help,

Thanks.
atrol
Site Admin
Posts: 8366
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: FTP Upload - APPLICATION ERROR #503

Post by atrol »

MantisNooby wrote: PHP is 5.3.0
I don't know if this is related to your issue, but 5.3.0 is quite buggy and there are known bugs when MantisBT is used with this version.
So you should update to 5.3.3 (or downgrade to 5.2.14)
Is there any reason why you use FTP and not DISK method for upload ?
Please use Search before posting and read the Manual
istvanb
Posts: 226
Joined: 22 Aug 2010, 21:00

Re: FTP Upload - APPLICATION ERROR #503

Post by istvanb »

Is there a "recommended" method to store the attachments? I store everything in the database, I am wondering if the others have an advantage over this one. (besides the fact that files are easy to access if they are not in the database)
atrol
Site Admin
Posts: 8366
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: FTP Upload - APPLICATION ERROR #503

Post by atrol »

I think using the database is a good decision. It's the easiest way to have a simple backup and restore.
Also moving to another server will be simple.

The advantage of using disk storage is a faster upload and download.
There are also (older) databases which do not support storing of LOB's in a good way.

Another reason to use disk storage might be the use of a virus scanner to check uploads.
Please use Search before posting and read the Manual
MantisNooby
Posts: 9
Joined: 05 Oct 2010, 20:11

Re: FTP Upload - APPLICATION ERROR #503

Post by MantisNooby »

Sorry, the PHP version on the production server is 5.3.3. I had 5.3.0 on my local wamp server. There was no particular reason FTP was chosen over DISK other than convenience really.

One reason, Istvanb, that we decided not to store files in our database is because we didn't want our database to get bloated. We are going to be making backups everyday and when you store files to your DB, your DB size grows exponentially and we would be backing up the same uploaded files over and over again. This saves a lot of space.


I've finally managed to upload files now to our FTP server, but we are getting two red error lines at the top of Mantis now.

SYSTEM WARNING: ftp_put(): ftp://ftp.myserver.com/test1/\4e940e271 ... 3eb66d8e06: The filename, directory name, or volume label syntax is incorrect.
SYSTEM WARNING: chmod(): Invalid argument

I had to play around with the upload file path in manage projects because it didn't like taking share names with a $ symbol and wouldn't even accept basic folder paths found in C:\. The important thing now is that files are being uploaded though, I'm sure this is just some quirk that will work its way out or something.
lstewart
Posts: 2
Joined: 03 Nov 2010, 18:01

Re: FTP Upload - APPLICATION ERROR #503

Post by lstewart »

I am also getting the same type of error messages - we are using PHP 5.3.3, Mantis 1.2.3 and IIS 6.0

example... when I click Display for an attachment... errors but it still shows the attachment

SYSTEM WARNING: ftp_get(FTP://WatMantisFTP.mydomain.com/\eb2952 ... ee296bb91d): failed to open stream: Remote file already exists and overwrite context option not specified
FTP server reports 213 581
SYSTEM WARNING: ftp_get(): Error opening FTP://WatMantisFTP.mydomain.com/\eb2952 ... ee296bb91d
Last edited by lstewart on 03 Nov 2010, 20:37, edited 3 times in total.
MantisNooby
Posts: 9
Joined: 05 Oct 2010, 20:11

Re: FTP Upload - APPLICATION ERROR #503

Post by MantisNooby »

Hi again,

So we can upload files now to our FTP server as I mentioned in my last post. The Upload File Path automatically appends a backslash following your file path no matter what. Because my file path has forward slashes in it (my FTP address), I believe the error occurs due to forward and backward slashes in the same file path.

SYSTEM WARNING: ftp_put(): ftp://ftp.myserver.com/test1/\4e940e271 ... 3eb66d8e06: The filename, directory name, or volume label syntax is incorrect.
SYSTEM WARNING: chmod(): Invalid argument

My question to Atrol or someone familiar with the Mantis code is where can I comment out the section that produces the two warning lines above? What Mantis .php file contains the part that is for example "If file upload path is in incorrect format, write these warnings to page"? Since uploading does work, all we want are these warnings to disappear and we've got our problem solved.

Thanks again in advance.
atrol
Site Admin
Posts: 8366
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: FTP Upload - APPLICATION ERROR #503

Post by atrol »

Sorry, but I don't find the time to have a deeper look at this problem.
Just uncommenting the lines which produce the warnings will not be the solution.

Some links related to the issue, maybe the firts one contains some valuable information how to fix
http://www.mantisbt.org/bugs/view.php?id=7660
http://www.mantisbt.org/bugs/view.php?id=8495
http://www.mantisbt.org/bugs/view.php?id=3734

Probably when reading those issues you will notice that using FTP method is not the best choice and no one seems to be really interested to fix the problems.
So again the question: Why not simply use DISK method?
Please use Search before posting and read the Manual
MantisNooby
Posts: 9
Joined: 05 Oct 2010, 20:11

Re: FTP Upload - APPLICATION ERROR #503

Post by MantisNooby »

For anyone following this thread and interested in a solution for Mantis 1.2.3 (maybe others, don't know):

config_inc.php settings:

$g_file_upload_method = FTP;
$g_file_upload_ftp_server = 'name.myserver.com';
$g_file_upload_ftp_user = 'FTPuser';
$g_file_upload_ftp_pass = 'FTPpassword';
$g_absolute_path_default_upload_folder = 'XX.XX.X.XX'; (Make this the server IP address)

Make sure the 'Upload File Path' for the particular project under Manage Projects is empty.

The above settings removed the first red warning line I was getting.

Now we have to make a couple changes in C:\Inetpub\Mantis\core\file_api.php.

At Line 696 (Mantis 1.2.3) in this area of the code, comment out the attempted bolded line with a # starting with chmod.

This will remove the second red warning line I was getting.

Code: Select all

	switch( $t_method ) {
		case FTP:
		case DISK:
			#file_ensure_valid_upload_path( $t_file_path );

			if( !file_exists( $t_disk_file_name ) ) {
				if( FTP == $t_method ) {
					$conn_id = file_ftp_connect();
					file_ftp_put( $conn_id, $t_disk_file_name, $t_tmp_file );
					file_ftp_disconnect( $conn_id );
				}

				if( !move_uploaded_file( $t_tmp_file, $t_disk_file_name ) ) {
					trigger_error( FILE_MOVE_FAILED, ERROR );
				}

				[b]#chmod( $t_disk_file_name, config_get( 'attachments_file_permissions' ) );[/b]

				$c_content = "''";
			} else {
				trigger_error( ERROR_FILE_DUPLICATE, ERROR );
			}
			break;
Before this I was coming across similar red warning lines when I would click 'Show Content' of the file in a particular issue and there were also some problems trying to download the file. Commenting out the above line also fixed these problems.


I also did not like the file names created on the FTP server in hash code (although they were done so to prevent duplicate file errors). In order to change the uploaded file names on the FTP server to be more easily identifiable without causing duplicate file errors, I prepended the actual file name to the hash code.

On Lines 665 and 666 (approximately 30 lines above the chmod line we commented out), I changed the previous code from:

Code: Select all

	$t_disk_file_name = $t_file_path . $t_unique_name;
	$c_unique_name = db_prepare_string( $t_unique_name );

to:

Code: Select all

	$t_disk_file_name = $t_file_name . '-' . $t_unique_name;
	$c_unique_name = db_prepare_string( $t_file_name . '-' . $t_unique_name );
Like I said, this was a solution for me. I am posting this for others because I know how frustrating it is to try and get the FTP upload method working.

-MantisNooby :)
Post Reply