Mantis Logo
Mantis Manual
Manual
Configuration

Database
Path
Webserver
Version
Email
Language
Display
Time
JpGraph
Date
News
Default Preferences
Summary
Bugnote
File Upload
HTML
Authentication
Status Settings
Filters
Misc
Colors
Cookies
Database Tables
Speed Optimisation
Reminders
Bug History
Sponsorship
Source Control Integration
Custom Fields
My View Settings
Relationships
System Logging


Partner Links


File Upload
Last Modified: August 5, 2003 07:08AM
(Any)
Description

Mantis allows users to upload file attachements and associated them with bugs as well as projects. Bug attachments / project documents can be uploaded to the webserver, database, or an FTP server. When bugs are uploaded to the webserver they are uploaded to the path that is configured in the project properties.

In case of problems getting the file upload feature to work, check the following resources:
$g_allow_file_upload Whether to allow/disallow uploading of attachments. Default value is ON.
$g_file_upload_method Specify the location for uploading attachements. This can be DISK, DATABASE, or FTP. In case of FTP, the files are saved on the webserver (same as disk) as well as on the specified FTP server. Default value is DATABASE.

In case of DISK / FTP upload methods you need to provide the webserver with write access rights to the configured upload path (configured in the project) and temporary upload path (used by PHP).
$g_max_file_size The maximum file size to allow as an attachment.
You may also have to configure your php.ini file to increase the execution time, memory limit, max post size, and max upload size.
$g_file_upload_ftp_server Address of the FTP server to write to (eg: ftp.example.com). This option is only effective if upload method is FTP.
$g_file_upload_ftp_user FTP user name for account to be used in uploading files to the FTP server. This account must have read/write access to the FTP server. The default path for the account is used for uploading the files.
$g_file_upload_ftp_pass Password to use when loggin in to the FTP server.
$g_max_file_size Maximum file size that can be uploaded. Default value is about 5MB.
The max file upload size is also affected by the value specified in php.ini. The PHP value is usually defaulted to 2MB.
$g_allowed_files Files that are allowed. Separate items by commas. eg. "zip,bmp,gif,jpg,txt" If $g_allowed_files is filled in NO other file types will be allowed. If empty it will assume any files are accepted that pass the $g_disallowed_files list.
$g_disallowed_files Files that are not allowed. Separate items by commas. eg. "php,php3,phtml,html,class,java,exe,pl" $g_disallowed_files takes precedence over $g_allowed_files.
It is recommended to disable all extensions that can be executed by your server.
$g_document_files_prefix Prefix to give to uploaded files when saved to the upload directory. This is used for documents that are attached to projects in order to be able to differentiate them from files that are attached to bugs. The name of the file has the following format prefix-projectcode-filename. The default value is 'doc'.
$g_preview_attachments_inline_max_size This feature applies to bmp, jpg, gif, and png files that are attached to bugs. If the file size is smaller than the specified values, the actual image is also previewed with the bugs. This feature can be disabled by setting the max size to 0. The default value is 0.

User Contributed Notes
File Upload
Add Notes About Notes
jp@PasDePourrielftz.fr
31-Oct-2003 1:28
#17
There are several place to define the maximum file size that can be uploaded :

In Mantis configuration file: config_defaults_inc.php or config_inc.php
$g_allow_file_upload = ON;
$g_max_file_size = 2000000; # 2 MB
$g_file_upload_method = DATABASE;

In the PHP configuration file : /etc/php.ini
upload_max_filesize = 2M

In the php Apache module : /etc/httpd/conf.d/php.conf The variable is LimitRequestBody (default to 512kB)
<Files *.php>
SetOutputFilter PHP
SetInputFilter PHP
LimitRequestBody 2097152
</Files>

If the update method is DATABASE, MySQL can also limit the file size
In /etc/my.cnf the variable max_allowed_packet must be defined.
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
set-variable = max_allowed_packet=5000000
stephan.grund@isst.fraunhofer.de
19-Jan-2004 3:02
#51
When changing from upload_method DATABASE to DISK for an existing database, is there a simple method to extract the existings files from the database?
rspatz AT 4w.com
09-Feb-2004 16:09
#67
After installing Mantis(version 0.18.1) I had problems getting file upload to work because of the open_basedir restrictions on my server wouldn't let php access the uploaded files from the temporary directory.

I found out that php can use the function move_uploaded_file() instead of copy(). After changing the $g_file_upload_method to DISK and making a 1 line change in core/file_api.php and proj_doc_add.php files.

core/file_api.php
Line 366
From: copy( $p_tmp_file, $t_file_path . $t_new_file_name );
To: move_uploaded_file( $p_tmp_file, $t_file_path . $t_new_file_name );

proj_doc_add.php
Line 74
From: copy( $v_tmp_name, $t_file_path . $t_file_name );
To: move_uploaded_file( $v_tmp_name, $t_file_path . $t_file_name );

ciappi@plsremovethisemail.it
15-Apr-2004 6:57
#107
Hi!
I use DATABASE to save files but I don't really how files are stored. My problem is that I periodically backup up the db using MySqlAdmin and the .sql generated string do not include (of course) the file...how is supposed I have to proceed to backup EVERYTHING (attachments included) on the db?
Thanks for help.

Ps: pls remove the "plsremovethis" to reply me
cdeady@aimltd.co.uk
22-Apr-2004 9:50
#121
Hi Ciappi

Backup MySQL can be done by locking the database, copying the database files and then unlocking. Full details can be found in the MySQL documentation.

-Colin
a.matichin@ulybin.com
02-Jul-2004 8:20
#163
 I have a problem with file upload using $g_file_upload_method = DATABASE. File uploaded successfully, but when I tryed to see uploaded file ann error message was shown :"The image “http://127.0.0.1/file_download.php?file_id=5&type=bug” cannot be displayed, because it contains errors."

Please help me to resolve this problem.
schiessler at gisquadrat dot com
06-Jul-2004 12:27
#167
I have same trbls with download of stored files (tried DISK and DATABASE). I guess IE6 cannot treat with mime types mantis provide. text files work, all other types do not work (size is ok, manually checked).

jfetzik at sandc.com
22-Jul-2004 15:03
#177
I have found a total of four settings that effect file uploads. Make sure they are all set to the value you need.

Mantis - $g_max_file_size
PHP - upload_max_filesize and post_max_size
MySql - max_allowed_packet, when using DATABASE upload method


Also beware of proxy servers between you and Mantis when uploading files. There is a 'bug' in some version of Microsoft ISA server that effects the POST method. The end result with Mantis being that ISA will timeout before the upload completes.
baiz@NOSPAMto-in.co.jp
10-Nov-2004 3:57
#259
I enabled $g_preview_attachments_inline_max_size so that I can display every attached images in the bug view. Although this decrease the load speed a little but it it very convenient for showing cosmetic bugs.

I want to add auto-resize (width and height) code for large image in the bug view, but by looking through the source code I couldn't find a way to access the image file.

How I wanted to do is use getimagesize() function to get image's width and height value, calculate the matrix for resized large images, and insert the 'width="" height=""' code to line 201 in file_api.php:

PRINT "<br /><img src=\"file_download.php?file_id=$v_id&amp;type=bug\" />";

Has anybody tried this before?
admin@b-alive.de
17-Nov-2004 10:43
#262
I`ve successfully installed mantis and edited the config_inc.php for storing upload files to DISK via FTP on a local server (adminstrated with cesarftp). (mantis is on our webhosting)
set user and password in config_inc.php...and realized while reporting an issue a successful login on the server by the php-script while submitting the issue. Nevertheless there is no "physical" data arrived on the server. Assuming that it is only cached in the database on the sql-server. Another hint for this problem is that the "uploadfilepath"-input-form per project accepts only the value "./". I want to set the path to "/QA" (tried it already in other variations ../ ./, etc. )on our local file server, and i want to have a "hardcopy" of the uploaded file in that targeted directory?! How can i solve this problem?
ivenco@ukr.net
29-Nov-2004 6:00
#273
please help - where to specify file upload path, when I set $g_file_upload_method = DISK; ?

Thanks!
mno_at_shd.de
03-Dec-2004 2:18
#278
an SQL dump actually DOES contain all the binary data. So one does not need to copy database files and do other tricks to backup the attachments. mysql dump is enough :)


INSERT INTO mantis_bug_file_table VALUES (8,250,'','','0000250-BelegAktualisierenNachKunde.gif','0000250-BelegAktualisierenNachKunde.gif','',31173,'image/gif','2004-09-07 09:36:23','GIF87a\0èw\0\0,\0\0\0\0\0è‡\0\0\0€\0\0\0€\0€€\0\0\0€€\0€\0€€ÀÀÀÀÜÀ¦Êð\0\033\0\03\03\033\"\"\";)))UUUMMMBBB999ÿ|€ÿPPÖ\0“ÌìÿïÖÆççÖ­©?3ÿ\0f\0\0™\0\0Ì\0\0\03\033\0f3\0™3\0Ì3\0ÿ3\0\0f\03f\0ff\0™f\0Ìf\0ÿf\0\0™\03™\0f™\0™™\0Ì™\0ÿ™\0\0Ì\03Ì\0fÌ\0™Ì\0ÌÌ\0ÿÌ\0fÿ\0™ÿ\0Ìÿ\0\0ÿ33\0ÿf\03™\03Ì\03ÿ\03\03ÿ333f33™33Ì33ÿ33\0f33f3ff3™f3Ìf3ÿf3\0™33™3f™3™™3Ì™3ÿ™3\0Ì33Ì3fÌ3™Ì3ÌÌ3ÿÌ33ÿ3fÿ3™ÿ3Ìÿ3ÿÿ3\0\0
bill at beansbox dot com
10-Dec-2004 2:30
#284
You can set the upload for DISK method in the project configuration of each project
mike_c_johnson@comcast.net
01-Feb-2005 18:29
#340
I am having an issue with the upload feature. I have the global set to DISK. When I click the Upload file button, I get Application Error #200 - A required parameter to this page was not found. This looks like it getting ERROR_GPC_VAR_NOT_FOUND most likely in the function gpc_get_file. Has anyone run into this before? Any help would be appreciated.

Thanks
powertester@126.com
02-Mar-2005 22:43
#368
i have a problem in upload file where be stored.
$g_file_upload_method=DATABASE,
and assumed project attachments be stored in c:/mantis/bugImages/
but i don't find attachments in c:/mantis/bugImages/
buescher@tiki-lounge
17-Mar-2005 18:17
#382
I've reported the misleading error messages and inconsistent user interface for uploading files as a bug at

http://bugs.mantisbt.org/view.php?id=5346

This might help if you just can't get file uploading to work :).
chrisludt AT gmx DOT de
10-Aug-2005 10:13
#562
Watch out if you are using PHP 5.0.4:

Don't be confused, if your files have a miximum size of 2 MB after the download. The file has been uploaded completely and successfully. It is a bug in the readfile function of PHP 5.0.4.
heike@DELETETHIScipsoft.com
12-Sep-2005 4:02
#601
There is an error in the core/database_api.php when you use postgres sql.

line 300 is: return pg_escape_string( $p_string );
but it must be: return pg_escape_bytea( $p_string );
otherwise all files will be corrupt after upload.

Heike
leon_99@gmx.net
12-Sep-2005 10:39
#602
Hello there,
I have two problems with the file upload in mantis 0.19.2:

1)
after changing the file-upload method from FTP to DISK, new files are not saved on the webserver with real names any more. Instead the files are saved with random characters and numbers and without a file-extension! What could be the reason for that?

2)
Is it possible to change the file-upload-path in the mantis project section together with changing the paths for all existing bugs having this path? In this moment the new path just works with new bugs, but not with the existing ones!

Thanks in advance
Leon_99
corinliu@gmail.com
06-Nov-2005 23:33
#701
Automatically included users cannot view documents in private projects. To fix this problem, use below solution.
open file: proj_doc_page.php
add:
$t_private_project_threshold = config_get( 'private_project_threshold' );

change:
$query = ...
...
( pult.user_id = $t_user_id AND pult.access_level $t_access_clause ) )
ORDER BY pt.name ASC, pft.title ASC";

to
( (pult.user_id = $t_user_id AND pult.access_level $t_access_clause) OR
(ut.access_level >= $t_private_project_threshold AND ut.access_level $t_access_clause)) )
ORDER BY pt.name ASC, pft.title ASC";
Arcnet.nl
09-Nov-2005 6:45
#708
[Editor] The following post was reported on the forums by Arcnet.nl.

Took me some time to find out why my uploads didn't work.

I use method 'DISK'.

Wanted to upload a new file to my 'Documents' section (All projects). But always got a failure.

So i found the variable '$g_absolute_path_default_upload_folder' ... and now it works. But this variable is not documented (in the Upload File section). Why not ?
themmer_at_go-engineering_dot_dee_ee
10-Nov-2005 8:52
#718
Also be sure to set memory_limit to a sufficient value in your php.ini.
I recently ran into trouble trying to upload a 1MB file although all beforementioned params were set appropriately.
After replacing the standard value of 8M by 16M everything worked fine.

Cheers, Thomas
m.grenz@web.de
16-Dec-2005 2:33
#773
Hi,
I changed all the parameters to 60M, so I can Upload big project-files. But in mantis the maximum filesize is 16.000k. Why?
I changed the php.ini, the confic_inc.php and the my.cfg. None of these contains the string 16M, or equal. Is there another file to change? Or is 16M the maximum?
terence@gamebrains.com
11-Jan-2006 20:36
#825
Hi,

I uploaded a bunch of files to mantis yesterday but today. All JPG's under the limit. Today when I go back in, I find the files missing. Could it be because it is being uploaded to a temp directory? How do you go about changing the place where files are uploaded?
shashimsc@gmail.com
10-Feb-2006 1:30
#883
I am using following in config_inc.php
$g_allow_file_upload = ON;
#db store,2 disk-1 ftp-3
$g_file_upload_method= '2';
$g_preview_attachments_inline_max_size='0';

Files are missing from the database. Why it is happening i couldn't understand. can anybody plz suggest.
wlingchen@yahoo.com
23-Feb-2006 5:02
#903
I am using Mantis 0.19.0, and my IE hangs when I upload a file which is over 1MB. I check config_inc.php and php.ini, and both are under default setting (2MB). Do I miss something?
ionut_juncu@yahoo.com
12-Apr-2006 5:32
#992
Hi all,

I have installed Mantis 1.0.1 (The latest stable version);
Windows 2003 platform; (AMD Athlon (TM)XP 1700+, 512 MB RAM )
IIS web server;
Mysql server version 5.0.15-nt via TCP/IP
Mysql client client version 5.0.11
php-5.0.5-Win32.
additional instalations:
mysql-query-browser-1.1.17-win.msi
mysql-connector-odbc-3.51.12-win32.msi
mysql-administrator-1.1.4-win.msi

So, i have some issues regarding upload path,

on php.ini
file_uploads = TRUE
upload_tmp_dir = C:\PHP\uploadtemp
upload_max_filesize = 20M

On config_defaults_inc.php
$g_allow_file_upload = ON;
g_file_upload_method = DISK;
$g_max_file_size = 5000000; # 5 MB
$g_document_files_prefix = 'doc';
$g_absolute_path_default_upload_folder = 'C:\PHP\uploadtemp';

When i upload the "example: fileupload.zip"
in "C:\PHP" i have the uploaded file in this format:
uploadtemp6b185d8b5eaf84cc03e8085d25a8a0c4

- How can i correct this please
PS: i just expected to see the file in C:\PHP\uploadtemp, with name fileupload, but i didn't get'it :(
Same problem with g_file_upload_method = FTP;

Thank you very much in advance
IonutJ
 
m.grenz@web.de
20-Apr-2006 10:25
#1016
Hello all,

I described the problem last december. I installed the new mantis version and still have the same problem. The maximum upload filesize ist 16000K. I edited the my.cnf, php5.ini and the config_inc.php. I can't even find a file with 16M or equal as value.
Is 16M the maximun filesize in mantis?

I use mySQL 5, php5 and apache2.

Can anyone help me?

Thanks
nobody@home.today
01-Jun-2006 14:39
#1109
I had a similar problem where i couldnt upload more than a 9mb or 14 mb file (seemed to vary a bit by platform/browser) regardless of all my php.ini, my.cnf, config_inc.php file settings.

None of the usual savvy folks who can usually fix anything could figure out why it wouldnt work. but what ended up fixing it was changing the file upload schema to DISK, that worked right away (so i figure it probably had something to do with all the multiple cachnig that goes one with php/sql temp files and such).

Anyway, switching to DISK didnt get us out of the woods so fast because it looks like there is a bug in Mantis as follows:

- It is not enough to merely set your config_inc.php setting (example):
$g_absolute_path_default_upload_folder = '/home/httpd/mantis/mantis-files/';

In order to use the admin/move_db2disk.php feature you MUST also set, in Manage Projects section for each and every project, set the upload path as well in order for the script to work, otherwise you get the "not writable" errors.
Add Notes About Notes
Last updated: Wed, 20 Aug 2008 - 5:33:55

Mantis @ SourceForge