Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tl_estate
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hujun
tl_estate
Commits
ac69cd57
Commit
ac69cd57
authored
Dec 03, 2018
by
zhuwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug
parent
97cd240a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
27 deletions
+39
-27
News.php
application/index/controller/News.php
+29
-27
SFile.php
application/model/SFile.php
+10
-0
No files found.
application/index/controller/News.php
View file @
ac69cd57
...
@@ -201,35 +201,36 @@ class News extends Basic
...
@@ -201,35 +201,36 @@ class News extends Basic
}
}
/**
* 附件下载并替换文件名
*
*/
public
function
downloadFile
()
{
public
function
downloadFile
()
{
$data
[]
=
[
'file_name'
=>
'12'
,
'file_former_name'
=>
'44'
];
if
(
empty
(
$this
->
params
[
'file_id'
]))
{
$data
[]
=
[
'file_name'
=>
'12'
,
'file_former_name'
=>
'44'
];
echo
"<script>alert('文件不存在')</script>"
;
return
$this
->
response
(
200
,
$data
);
}
$field
=
'id,file_name,annex_file_name'
;
$where
[
'status'
]
=
0
;
// dump(666);exit;
$where
[
'id'
]
=
$this
->
params
[
'file_id'
];
// $this->params['file_name']= '20181203/20181203110021473.jpg';
$m_file
=
new
SFile
();
// $this->params['file_former_name']='ceshi.jpg';
$data
=
$m_file
->
getFileById
(
$field
,
$where
);
// if (empty($this->params['file_name']) or empty($this->params['file_former_name'])) {
// echo "<script>alert('文件不存在')</script>";
// }
$file_name
=
$data
[
'file_name'
];
//
$file_former_name
=
$data
[
'file_former_name'
];
// $file_name = $this->params['file_name'];
// $file_former_name = $this->params['file_former_name'];
$filepath
=
ROOT_PATH
.
'public/static/business_school_file/'
.
$file_name
;
//
if
(
file_exists
(
$filepath
)){
// $filepath = ROOT_PATH . 'public/static/business_school_file/'.$file_name;
header
(
"Content-type:application/octet-stream"
);
// if(file_exists($filepath)){
$filename
=
basename
(
$filepath
);
// header("Content-type:application/octet-stream");
header
(
"Content-Disposition:attachment;filename =
{
$file_former_name
}
"
);
// $filename = basename($filepath);
header
(
"Accept-ranges:bytes"
);
// header("Content-Disposition:attachment;filename = {$file_former_name}");
header
(
"Accept-length:"
.
filesize
(
$filepath
));
// header("Accept-ranges:bytes");
readfile
(
$filepath
);
// header("Accept-length:".filesize($filepath));
}
else
{
// readfile($filepath);
echo
"<script>alert('文件不存在')</script>"
;
// }else{
}
// echo "<script>alert('文件不存在')</script>";
// }
}
}
}
}
\ No newline at end of file
application/model/SFile.php
View file @
ac69cd57
...
@@ -76,4 +76,13 @@ class SFile extends BaseModel
...
@@ -76,4 +76,13 @@ class SFile extends BaseModel
->
order
(
$order
)
->
order
(
$order
)
->
select
();
->
select
();
}
}
public
function
getFileById
(
$field
=
''
,
$params
=
''
)
{
return
$this
->
field
(
$field
)
->
where
(
$params
)
->
find
();
}
}
}
\ No newline at end of file
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