当前位置:网站首页>Micro engine remote attachment 7 Niu cloud upload
Micro engine remote attachment 7 Niu cloud upload
2022-06-25 12:33:00 【Stewed mushroom with Xiaoji·】
<?php
// Upload files The server Go from the server to qiniu cloud Also delete server files
$setting = $_W["setting"]["upload"]["image"];
$compressed = !empty($_GPC["compressed"]) ? $_GPC["compressed"] : 0;
$ext = '';
switch ($_FILES["file"]["type"]) {
case "application/x-jpg":
case "image/jpeg":
$ext = "jpg";
break;
case "image/png":
$ext = "png";
break;
case "image/gif":
$ext = "gif";
break;
default:
$result["message"] = " Failed to extract resources , Wrong resource file type .";
$return["code"] = 1;
$return["msg"] = " Failed to upload resources , Wrong resource file type .";
echo json_encode($return);
exit;
break;
}
if (intval($_FILES["file"]["size"]) > $setting["limit"] * 1024) {
$return["code"] = 1;
$limit = $setting["limit"] * 1024;
$return["msg"] = " The uploaded media file is larger than (" . $limit . ")";
echo json_encode($return);
exit;
}
if (empty($_FILES["file"]["name"])) {
$return["code"] = 1;
$return["msg"] = " Upload failed , Please select the file to upload !";
echo json_encode($return);
exit;
}
if ($_FILES["file"]["error"] != 0) {
$return["code"] = 1;
$return["msg"] = " Upload failed , Please try again .";
echo json_encode($return);
exit;
}
$ext = pathinfo($_FILES["file"]["name"], PATHINFO_EXTENSION);
$ext = strtolower($ext);
$filename = random(30) . "." . $ext;
/*load()->func('file');
$file = usedcar_file_upload($compressed, $_FILES["file"], "image", $filename);
*/
$filepath = 'images/' . $this->modulename . '/' . $filename;
load()->func('file');
// return json_encode($_FILES['upfile']);
$file=file_upload($_FILES['file'], 'image',$filepath);
$pathname = $file["path"];
// print_r($pathname);
// exit;
if (!empty($_W['setting']['remote']['type'])) { // Determine whether the system has enabled the remote attachment
$remotestatus = file_remote_upload($pathname); // Upload pictures to remote
if (is_error($remotestatus)) {
message(' Remote attachment upload failed , Please check the configuration and upload again ');
} else {
$remoteurl = tomedia($pathname); // Remote picture access URL
// $pathname perhaps $remoteurl( Full link )// Local address to be stored and warehoused
}
}
$return["code"] = 0;
$return["data"]["src"] = $remoteurl;
$return["msg"] = " Upload successful ";
echo json_encode($return);
exit;
print_r($file);
echo $file;
exit;
?>边栏推荐
- Set the transparency of the picture to gradient from left to right
- Learning notes 2022 overview | automatic graph machine learning, describing AGML methods, libraries and directions
- 一篇文章讲清楚MySQL的聚簇/联合/覆盖索引、回表、索引下推
- Huikan source code -- Huikan app system secondary development source code sharing
- Image tagging to obtain the coordinates of the image in the ImageView
- Implementing Domain Driven Design - using the ABP framework - Summary of a series of articles
- How to use ARIMA model for prediction?
- Heyangdao store management system -- share the development source code of heyangdao system
- 2022 meisai e topic ideas sharing + translation
- Concise H5 error page
猜你喜欢

Rank sum ratio comprehensive evaluation method for common models in mathematical modeling

The first techo day Tencent technology open day in 2022 will be held online on June 28

Time series analysis - how to use unit root test (ADF) correctly?
![[论]Learning Dynamic and Hierarchical Traffic Spatiotemporal Features with Transformer](/img/58/d68112a3d019de66150e2f5102f436.png)
[论]Learning Dynamic and Hierarchical Traffic Spatiotemporal Features with Transformer

SDN system method | 9 Access network

Explain AHP in human language (very detailed principle + simple tool implementation)
![[oceanbase] Introduction to oceanbase and its comparison with MySQL](/img/1c/bd2bcddb7af4647407d2bc351f5f5d.png)
[oceanbase] Introduction to oceanbase and its comparison with MySQL

Dark horse shopping mall ---6 Brand, specification statistics, condition filtering, paging sorting, highlighting

揭秘GaussDB(for Redis):全面對比Codis
![[on]learning dynamic and hierarchical traffic spatiotemporal features with transformer](/img/58/d68112a3d019de66150e2f5102f436.png)
[on]learning dynamic and hierarchical traffic spatiotemporal features with transformer
随机推荐
The first techo day Tencent technology open day in 2022 will be held online on June 28
The source code of the hottest online disk money making system in 2022 imitates Lanzou online disk / Chengtong online disk / sharing money making cloud disk system / online disk VIP Download System
A commonly used statistical modeling method -- difference analysis
一套自动化无纸办公系统(OA+审批流)源码:带数据字典
Why do we do autocorrelation analysis? Explain application scenarios and specific operations
R language dplyr package filter function filters the data rows in the specified list whose contents in the dataframe data are not (not equal to one of the specified vectors)
R语言使用epiDisplay包的followup.plot函数可视化多个ID(病例)监测指标的纵向随访图、使用stress.type参数指定强调线的id子集的线条的类型(type)
What is the primordial universe
MySQL common interview questions
Kotlin Foundation
sudo: ulimit: command not found
devsecops与devops的理解与建设
An article clearly explains MySQL's clustering / Federation / coverage index, back to table, and index push down
Introduction to jiuhongtianxia system development function -- jiuhongtianxia app development source code sharing
Today, I will explain to you what is DFI and its development prospects
Explain factor analysis in simple terms, with case teaching (full)
Possible causes of wechat applet decryption failure
Online blind box system development function introduction and some source code sharing
网络上开户买股票是否安全呢?
Tp6 exception handling try catch writing method