当前位置:网站首页>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;
?>边栏推荐
- Install MySQL client
- Set the transparency of the picture to gradient from left to right
- R language uses the multinom function of NNET package to build an unordered multi classification logistic regression model, and uses the lrtest function of epidisplay package to perform multiple model
- R语言使用scale函数对神经网络的输入数据进行最小最大缩放、把数据缩放到0到1之间、并划分数据集为训练集和测试集
- What is Flink? What can Flink do?
- Update of complex JSON in MySQL
- ECSHOP quickly purchases goods, simplifies the shopping process, and improves the user experience through one-step shopping
- 2022 meisai topic C idea sharing + translation
- 一篇文章讲清楚MySQL的聚簇/联合/覆盖索引、回表、索引下推
- Development with courtesy -- share the source code of the secondary development of the app system of the imitation shopping mall
猜你喜欢

Why do we do autocorrelation analysis? Explain application scenarios and specific operations

Understanding and construction of devsecops and Devops

K8s, docker compose install MySQL 8.0.18

刷入Magisk通用方法

【OceanBase】OceanBase简介及其与MySQL的比较

15、wpf之button样式小记

Découvrir gaussdb (pour redis): une comparaison complète avec 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

20. MVVM command binding of WPF

MySQL common interview questions
随机推荐
Explanation of ideas and sharing of pre-processing procedures for 2021 US game D (with pre-processing data code)
20、wpf之MVVM命令绑定
Wait for the end of the network request in the uniapp Onshow method before executing the subsequent code content
The R language cartools package divides data, the scale function scales data, and the NaiveBayes function of e1071 package constructs a naive Bayesian model
How do super rookies get started with data analysis?
Learning notes 2022 overview | automatic graph machine learning, describing AGML methods, libraries and directions
刷入Magisk通用方法
Dark horse shopping mall ---2 Distributed file storage fastdfs
Service charge and time setting code sharing involved in crmeb withdrawal process
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)
PHP multidimensional array sorting
If you also want to be we media, you might as well listen to Da Zhou's advice
ARM V7 协处理器
15. Notes on the button style of WPF
R语言使用scale函数对神经网络的输入数据进行最小最大缩放、把数据缩放到0到1之间、并划分数据集为训练集和测试集
Mpai data science platform SVM support vector machine classification \ explanation of regression parameter adjustment
Yunfan mall -- Yunfan mall system development source code sharing
Set the transparency of the picture to gradient from left to right
Full nanny tutorial of Market Research Competition (experience sharing)
What is the primordial universe