Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuy-portal-fe
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
weiqingting
9 years ago
Commit
51054b503549f2548427704b11d65faafd7c8121
1 parent
5c086738
批量上传
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
32 deletions
client/js/common/edit.js
server/stub/service/upload.js
client/js/common/edit.js
View file @
51054b5
...
...
@@ -141,20 +141,7 @@ edit.prototype={
Temp
+=
'</ul>'
;
$
(
this
).
after
(
Temp
);
});
edit
.
ajaxfileupload
(
that
.
el
+
" input[type='file']"
,{
'params'
:{
"userId"
:
543883
,
"bucket"
:
'smart'
},
'onComplete'
:
function
(
response
)
{
var
_w
=
$
(
this
).
next
().
find
(
'.fileinput-button-icon'
);
if
(
_w
.
find
(
'img'
).
length
>
0
){
_w
.
find
(
'img'
).
attr
(
"src"
,
response
.
data
);
}
else
{
_w
.
prepend
(
'<img width="76" height="80" src="'
+
response
.
data
+
'">'
);
}
$
(
this
).
attr
(
"value"
,
response
.
data
);
}
});
// $('input[type="file"]',that.el).ajaxfileupload({
// 'action': '/ajax/upload',
// edit.ajaxfileupload(that.el+" input[type='file']",{
// 'params':{"userId":543883,"bucket":'smart'},
// 'onComplete': function(response) {
// var _w=$(this).next().find('.fileinput-button-icon');
...
...
@@ -164,12 +151,25 @@ edit.prototype={
// _w.prepend('<img width="76" height="80" src="'+response.data+'">');
// }
// $(this).attr("value",response.data);
// },
// 'onStart': function() {
// },
// 'onCancel': function() {
// }
// });
$
(
'input[type="file"]'
,
that
.
el
).
ajaxfileupload
({
'action'
:
'/ajax/upload'
,
'params'
:{
"userId"
:
543883
,
"bucket"
:
'smart'
},
'onComplete'
:
function
(
response
)
{
var
_w
=
$
(
this
).
next
().
find
(
'.fileinput-button-icon'
);
if
(
_w
.
find
(
'img'
).
length
>
0
){
_w
.
find
(
'img'
).
attr
(
"src"
,
response
.
data
);
}
else
{
_w
.
prepend
(
'<img width="76" height="80" src="'
+
response
.
data
+
'">'
);
}
$
(
this
).
attr
(
"value"
,
response
.
data
);
},
'onStart'
:
function
()
{
},
'onCancel'
:
function
()
{
}
});
}
that
.
__listen
(
"render"
);
...
...
server/stub/service/upload.js
View file @
51054b5
...
...
@@ -8,15 +8,19 @@ exports.uploadFile=function(req,res){
// 方法1
if
(
req
.
is
(
"multipart/form-data"
)){
req
.
body
.
file
=
fs
.
createReadStream
(
req
.
files
[
req
.
body
.
filename
].
path
);
if
(
req
.
body
.
type
==
"batch-import"
){
request
.
post
({
url
:
domain
+
'/batch/import'
,
formData
:
req
.
body
},
function
optionalCallback
(
err
,
httpResponse
,
body
){
res
.
json
(
JSON
.
parse
(
body
));
});
}
else
{
request
.
post
({
url
:
domain
+
'/fileupload/upload'
,
formData
:
req
.
body
},
function
optionalCallback
(
err
,
httpResponse
,
body
){
// if(req.body.type=="batch-import"){
// request.post({url:domain+'/batch/import',formData:req.body},function optionalCallback(err, httpResponse, body){
// res.json(JSON.parse(body));
// });
// }else{
// request.post({url:domain+'/fileupload/upload',formData:req.body},function optionalCallback(err, httpResponse, body){
// res.json(JSON.parse(body));
// });
// }
request
.
post
({
url
:
domain
+
'/fileupload/upload'
,
formData
:
req
.
body
},
function
optionalCallback
(
err
,
httpResponse
,
body
){
res
.
json
(
JSON
.
parse
(
body
));
});
}
}
else
{
res
.
json
({
code
:
"500"
,
message
:
"请求类型错误"
});
...
...
@@ -27,11 +31,5 @@ exports.uploadFile=function(req,res){
// "message":"success"
// });
//方法2
// req.pipe(request.post(domain+'/fileupload/upload'))
// .on('error', onerror)
// .pipe(res);
// function onerror(err) {
// console.error(err.stack)
// }
}
\ No newline at end of file
...
...
Please
register
or
login
to post a comment