Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jqfileuploadbundle
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dj3c1t
jqfileuploadbundle
Commits
7499ea17
Commit
7499ea17
authored
Jan 10, 2016
by
dj3c1t
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
importMediaFromLocalFile
parent
06047001
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
3 deletions
+23
-3
UploadHandler.php
Service/UploadHandler.php
+3
-2
UploadManager.php
Service/UploadManager.php
+20
-1
No files found.
Service/UploadHandler.php
View file @
7499ea17
...
...
@@ -1088,7 +1088,7 @@ class UploadHandler
$file_path
=
$this
->
get_upload_path
(
$file
->
name
);
$append_file
=
$content_range
&&
is_file
(
$file_path
)
&&
$file
->
size
>
$this
->
get_file_size
(
$file_path
);
if
(
$uploaded_file
&&
is_uploaded_file
(
$uploaded_file
)
)
{
if
(
$uploaded_file
/* && is_uploaded_file($uploaded_file)*/
)
{
// multipart/formdata uploads (POST method uploads)
if
(
$append_file
)
{
file_put_contents
(
...
...
@@ -1097,7 +1097,8 @@ class UploadHandler
FILE_APPEND
);
}
else
{
move_uploaded_file
(
$uploaded_file
,
$file_path
);
// move_uploaded_file($uploaded_file, $file_path);
copy
(
$uploaded_file
,
$file_path
);
}
}
else
{
// Non-multipart uploads (PUT method support)
...
...
Service/UploadManager.php
View file @
7499ea17
...
...
@@ -354,7 +354,7 @@ class UploadManager {
}
public
function
getMedia
(
$file
)
{
$fileName
=
$file
->
name
;
$fileName
=
urldecode
(
$file
->
name
)
;
$media_dir
=
$this
->
rootDir
.
"/"
.
$this
->
mediaRootDir
.
"/"
.
$this
->
mediaDir
.
"/"
;
if
(
!
file_exists
(
$media_dir
.
$fileName
))
{
throw
new
\Exception
(
"unable to read file on disk"
);
...
...
@@ -424,6 +424,25 @@ class UploadManager {
return
$media
;
}
public
function
importMediaFromLocalFile
(
$fileName
)
{
$this
->
makeUploadDir
();
$finfo
=
finfo_open
(
FILEINFO_MIME_TYPE
);
$mime_type
=
finfo_file
(
$finfo
,
$fileName
);
finfo_close
(
$finfo
);
$fileSize
=
filesize
(
$fileName
);
$_FILES
=
array
(
"local"
=>
array
(
"name"
=>
basename
(
$fileName
),
"type"
=>
$mime_type
?
$mime_type
:
""
,
"tmp_name"
=>
$fileName
,
"error"
=>
0
,
"size"
=>
$fileSize
)
);
$_SERVER
[
'CONTENT_LENGTH'
]
=
$fileSize
;
return
$this
->
makeMediaFromFiles
(
"local"
);
}
public
function
delete_file
(
$file_name
)
{
if
(
$res
=
$this
->
jQUploadHandler
->
delete_file
(
$file_name
))
{
$this
->
cleanUploadDir
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment