Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
osticket
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
docker
osticket
Commits
f7649731
Commit
f7649731
authored
12 years ago
by
Peter Rotich
Browse files
Options
Downloads
Plain Diff
Merge pull request #484 from protich/fanha99-check_file_size
File size limit
parents
f7830285
4ff003f1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
include/ajax.config.php
+0
-2
0 additions, 2 deletions
include/ajax.config.php
js/jquery.multifile.js
+41
-15
41 additions, 15 deletions
js/jquery.multifile.js
js/osticket.js
+2
-1
2 additions, 1 deletion
js/osticket.js
scp/js/scp.js
+2
-1
2 additions, 1 deletion
scp/js/scp.js
with
45 additions
and
19 deletions
include/ajax.config.php
+
0
−
2
View file @
f7649731
...
...
@@ -24,8 +24,6 @@ class ConfigAjaxAPI extends AjaxController {
$config
=
array
(
'lock_time'
=>
(
$cfg
->
getLockTime
()
*
3600
),
'file_types'
=>
$cfg
->
getAllowedFileTypes
(),
'max_file_size'
=>
(
int
)
$cfg
->
getMaxFileSize
(),
'max_file_uploads'
=>
(
int
)
$cfg
->
getStaffMaxFileUploads
()
);
return
$this
->
json_encode
(
$config
);
...
...
This diff is collapsed.
Click to expand it.
js/jquery.multifile.js
+
41
−
15
View file @
f7649731
...
...
@@ -3,7 +3,9 @@
Multifile plugin that allows users to upload multiple files at once in unobstructive manner - cleaner interface.
Allows limiting number of files and file type(s) using file extension.
Allows limiting number of files
Whitelist file type(s) using file extension
Limit file sizes.
NOTE:
* Files are not uploaded until the form is submitted
...
...
@@ -50,7 +52,21 @@
if
(
fObj
.
data
(
'
files
'
)
>=
settings
.
max_uploads
||
(
fObj
.
data
(
'
files
'
)
+
file
.
count
)
>
settings
.
max_uploads
)
{
alert
(
'
You have reached the maximum number of files (
'
+
settings
.
max_uploads
+
'
) allowed per upload
'
);
}
else
if
(
$
.
fn
.
multifile
.
checkFileTypes
(
file
,
settings
.
allowedFileTypes
))
{
}
else
if
(
!
$
.
fn
.
multifile
.
checkFileTypes
(
file
,
settings
.
allowedFileTypes
))
{
var
msg
=
'
Selected file type is NOT allowed
'
;
if
(
file
.
count
>
1
)
msg
=
'
File type of one or more of the selected files is NOT allowed
'
;
alert
(
'
Error:
'
+
msg
);
$this
.
replaceWith
(
new_input
);
}
else
if
(
!
$
.
fn
.
multifile
.
checkFileSize
(
file
,
settings
.
max_file_size
))
{
var
msg
=
'
Selected file exceeds allowed size
'
;
if
(
file
.
count
>
1
)
msg
=
'
File size of one or more of the selected files exceeds allowed size
'
;
alert
(
'
Error:
'
+
msg
);
$this
.
replaceWith
(
new_input
);
}
else
{
$this
.
hide
();
settings
...
...
@@ -61,15 +77,6 @@
fObj
.
data
(
'
files
'
,
fObj
.
data
(
'
files
'
)
+
file
.
count
);
if
(
fObj
.
data
(
'
files
'
)
<
settings
.
max_uploads
)
$this
.
after
(
new_input
);
}
else
{
var
msg
=
'
Selected file type is NOT allowed
'
;
if
(
file
.
count
>
1
)
msg
=
'
File type of one or more of the selected files is NOT allowed
'
;
alert
(
'
Error:
'
+
msg
);
$this
.
replaceWith
(
new_input
);
}
}
...
...
@@ -126,6 +133,20 @@
if
(
filenames
[
i
]
&&
$
.
inArray
(
'
.
'
+
filenames
[
i
].
split
(
'
.
'
).
pop
(),
allowedFileTypes
)
==
-
1
)
return
false
;
return
true
;
};
$
.
fn
.
multifile
.
checkFileSize
=
function
(
file
,
MaxFileSize
)
{
//Size info not available or max file is not set (let server-side handle it).
if
(
!
MaxFileSize
||
!
file
.
size
)
return
true
;
var
filesizes
=
$
.
map
(
file
.
size
.
split
(
'
,
'
),
$
.
trim
);
for
(
var
i
=
0
,
_len
=
filesizes
.
length
;
i
<
_len
;
i
++
)
if
(
filesizes
[
i
]
>
MaxFileSize
)
return
false
;
return
true
;
};
...
...
@@ -150,16 +171,20 @@
file
.
count
=
1
;
// check for HTML5 FileList support
if
(
!!
global
.
FileList
)
{
if
(
input
.
files
.
length
==
1
)
if
(
input
.
files
.
length
==
1
)
{
file
.
name
=
input
.
files
[
0
].
name
;
else
{
//Multi-select
file
.
size
=
''
+
input
.
files
[
0
].
size
;
}
else
{
//Multi-select
// We do this in order to support `multiple` files.
// You can't display them separately because they
// belong to only one file input. It is impossible
// to remove just one of the files.
file
.
name
=
input
.
files
[
0
].
name
;
for
(
var
i
=
1
,
_len
=
input
.
files
.
length
;
i
<
_len
;
i
++
)
file
.
size
=
''
+
input
.
files
[
0
].
size
;
for
(
var
i
=
1
,
_len
=
input
.
files
.
length
;
i
<
_len
;
i
++
)
{
file
.
name
+=
'
,
'
+
input
.
files
[
i
].
name
;
file
.
size
+=
'
,
'
+
input
.
files
[
i
].
size
;
}
file
.
count
=
i
;
}
...
...
@@ -173,6 +198,7 @@
//Default options
$
.
fn
.
multifile
.
defaults
=
{
max_uploads
:
1
,
file_types
:
'
.*
'
file_types
:
'
.*
'
,
max_file_size
:
0
};
})(
jQuery
,
this
);
This diff is collapsed.
Click to expand it.
js/osticket.js
+
2
−
1
View file @
f7649731
...
...
@@ -64,6 +64,7 @@ $(document).ready(function(){
$
(
'
.multifile
'
).
multifile
({
container
:
'
.uploads
'
,
max_uploads
:
(
$config
&&
$config
.
max_file_uploads
)?
$config
.
max_file_uploads
:
1
,
file_types
:
(
$config
&&
$config
.
file_types
)?
$config
.
file_types
:
"
.*
"
file_types
:
(
$config
&&
$config
.
file_types
)?
$config
.
file_types
:
"
.*
"
,
max_file_size
:
(
$config
&&
$config
.
max_file_size
)?
$config
.
max_file_size
:
0
});
});
This diff is collapsed.
Click to expand it.
scp/js/scp.js
+
2
−
1
View file @
f7649731
...
...
@@ -259,7 +259,8 @@ $(document).ready(function(){
$
(
'
.multifile
'
).
multifile
({
container
:
'
.uploads
'
,
max_uploads
:
(
$config
&&
$config
.
max_file_uploads
)?
$config
.
max_file_uploads
:
1
,
file_types
:
(
$config
&&
$config
.
file_types
)?
$config
.
file_types
:
"
.*
"
file_types
:
(
$config
&&
$config
.
file_types
)?
$config
.
file_types
:
"
.*
"
,
max_file_size
:
(
$config
&&
$config
.
max_file_size
)?
$config
.
max_file_size
:
0
});
/* Datepicker */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment