手动判断文件名是否为空
This commit is contained in:
@@ -18,5 +18,6 @@
|
|||||||
"warehouses_api_err":15,
|
"warehouses_api_err":15,
|
||||||
"warehouses_name_err":16,
|
"warehouses_name_err":16,
|
||||||
"warehouses_id_err":17,
|
"warehouses_id_err":17,
|
||||||
"file_id_error":18
|
"file_id_error":18,
|
||||||
|
"file_name_err":19
|
||||||
}
|
}
|
||||||
@@ -23,11 +23,12 @@ func Router_file(r *gin.RouterGroup) {
|
|||||||
id := ctx.Param("id")
|
id := ctx.Param("id")
|
||||||
id_int, err := strconv.ParseInt(id, 10, 0)
|
id_int, err := strconv.ParseInt(id, 10, 0)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
if id_int != 0 {
|
||||||
//fmt.Println(id_int)
|
//fmt.Println(id_int)
|
||||||
file_info := models.File_info{
|
file_info := models.File_info{
|
||||||
ID: uint(id_int),
|
ID: uint(id_int),
|
||||||
}
|
}
|
||||||
if models.DB.Where(file_info.ID).First(&file_info).Error == nil {
|
if models.DB.Where(&file_info).First(&file_info).Error == nil {
|
||||||
fmt.Println(file_info)
|
fmt.Println(file_info)
|
||||||
} else {
|
} else {
|
||||||
fmt.Println("not fund")
|
fmt.Println("not fund")
|
||||||
@@ -40,6 +41,10 @@ func Router_file(r *gin.RouterGroup) {
|
|||||||
Return_json(ctx, "file_id_error", nil)
|
Return_json(ctx, "file_id_error", nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Return_json(ctx, "file_id_error", nil)
|
||||||
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
//先在中间件判断有没有传进cookie
|
//先在中间件判断有没有传进cookie
|
||||||
@@ -66,6 +71,8 @@ func Router_file(r *gin.RouterGroup) {
|
|||||||
file, err := ctx.FormFile("file")
|
file, err := ctx.FormFile("file")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|
||||||
|
if file.Filename != "" {
|
||||||
|
|
||||||
//限制文件大小
|
//限制文件大小
|
||||||
if file.Size > 512 {
|
if file.Size > 512 {
|
||||||
if file.Size < int64(models.Configs_file.Max_size) {
|
if file.Size < int64(models.Configs_file.Max_size) {
|
||||||
@@ -164,6 +171,11 @@ func Router_file(r *gin.RouterGroup) {
|
|||||||
|
|
||||||
Return_json(ctx, "file_size_err", nil)
|
Return_json(ctx, "file_size_err", nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Return_json(ctx, "file_name_err", nil)
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Return_json(ctx, "file_get_err", nil)
|
Return_json(ctx, "file_get_err", nil)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user