Php Alamofire Swift 5上传文件时出现问题?
我想用Php Alamofire Swift 5上传文件时出现问题?,php,ios,swift,alamofire,alamofire-upload,Php,Ios,Swift,Alamofire,Alamofire Upload,我想用 pod 'Alamofire', '~> 5.0.0-rc.3' 但是我在linux主机的文件夹中看不到该文件 upload.php文件: <?php if(isset($_FILES['image'])){ $errors= array(); $file_name = $_FILES['image']['name']; $file_size =$_FILES['image']['size']; $file_tmp =$
pod 'Alamofire', '~> 5.0.0-rc.3'
但是我在linux主机的文件夹中看不到该文件
upload.php文件:
<?php
if(isset($_FILES['image'])){
$errors= array();
$file_name = $_FILES['image']['name'];
$file_size =$_FILES['image']['size'];
$file_tmp =$_FILES['image']['tmp_name'];
$file_type=$_FILES['image']['type'];
$file_ext=strtolower(end(explode('.',$_FILES['image']['name'])));
$extensions= array("jpeg","jpg","png");
if(in_array($file_ext,$extensions)===false){
$errors[]="extension not allowed, please choose a JPEG or PNG file.";
}
if($file_size > 2097152){
$errors[]='File size must be excately 2 MB';
}
if(empty($errors)==true){
move_uploaded_file($file_tmp,"images/".$file_name);
echo "Success";
}else{
print_r($errors);
}
}
?>
func upload(image: UIImage,
progressCompletion: @escaping (_ percent: Float) -> Void,
completion: @escaping (_ result: Bool) -> Void) {
guard let imageData = image.jpegData(compressionQuality: 0.5) else {
print("Could not get JPEG representation of UIImage")
return
}
AF.upload(
multipartFormData: { multipartFormData in
multipartFormData.append(imageData,
withName: "imagefile",
fileName: "image.jpg",
mimeType: "image/jpeg")
},
to: "http://website.com/upload.php", usingThreshold: UInt64.init(), method: .post)
.uploadProgress { progress in
progressCompletion(Float(progress.fractionCompleted))
}
.response { response in
debugPrint(response)
}
}
@IBAction func getStartedBtnClicked(_ sender: Any) {
upload(
image: UIImage(named: "uploadFile.png")!,
progressCompletion: { [weak self] percent in
guard let _ = self else {
return
}
print("Status: \(percent)")
},
completion: { [weak self] result in
guard let _ = self else {
return
}
})
}
Status: 1.0
...
[Data]: 19034 bytes
[Network Duration]: 0.9285140037536621s
[Serialization Duration]: 0.0s
[Result]: success(Optional(19034 bytes))
Status: 1.0
...
[Data]: None
[Network Duration]: 0.3820209503173828s
[Serialization Duration]: 0.0s
[Result]: success(nil)
if let fileURL = Bundle.main.url(forResource: "uploadFile", withExtension: "png") {
AF.upload(fileURL, to: "http://website.com/upload.php").responseJSON { response in
debugPrint(response)
}
}
[Request Body]:
None
[Response]:
[Status Code]: 200
[Headers]:
Connection: Upgrade, Keep-Alive
Content-Length: 0
Content-Type: text/html; charset=UTF-8
Date: Wed, 18 Dec 2019 06:19:32 GMT
Keep-Alive: timeout=5
Server: Apache
Upgrade: h2,h2c
Vary: User-Agent
X-Powered-By: PHP/7.2.20
[Response Body]:
None
[Data]: None
[Network Duration]: 0.33376002311706543s
[Serialization Duration]: 0.0014129877090454102s
[Result]: failure(Alamofire.AFError.responseSerializationFailed(reason: Alamofire.AFError.ResponseSerializationFailureReason.inputDataNilOrZeroLength))
<?php
if(isset($_FILES['image'])){
$errors= array();
$file_name = $_FILES['image']['name'];
$file_size =$_FILES['image']['size'];
$file_tmp =$_FILES['image']['tmp_name'];
$file_type=$_FILES['image']['type'];
$file_ext=strtolower(end(explode('.',$_FILES['image']['name'])));
$extensions= array("jpeg","jpg","png");
if(in_array($file_ext,$extensions)=== false){
$errors[]="extension not allowed, please choose a JPEG or PNG file.";
}
if($file_size > 2097152){
$errors[]='File size must be excately 2 MB';
}
if(empty($errors)==true){
move_uploaded_file($file_tmp,"images/".$file_name);
echo "Success";
}else{
print_r($errors);
}
}
?>
<html>
<body>
<form action="" method="POST" enctype="multipart/form-data">
<input type="file" name="image" />
<input type="submit"/>
</form>
</body>
</html>
使用时:Swift代码中的区域为“”:
<?php
if(isset($_FILES['image'])){
$errors= array();
$file_name = $_FILES['image']['name'];
$file_size =$_FILES['image']['size'];
$file_tmp =$_FILES['image']['tmp_name'];
$file_type=$_FILES['image']['type'];
$file_ext=strtolower(end(explode('.',$_FILES['image']['name'])));
$extensions= array("jpeg","jpg","png");
if(in_array($file_ext,$extensions)===false){
$errors[]="extension not allowed, please choose a JPEG or PNG file.";
}
if($file_size > 2097152){
$errors[]='File size must be excately 2 MB';
}
if(empty($errors)==true){
move_uploaded_file($file_tmp,"images/".$file_name);
echo "Success";
}else{
print_r($errors);
}
}
?>
func upload(image: UIImage,
progressCompletion: @escaping (_ percent: Float) -> Void,
completion: @escaping (_ result: Bool) -> Void) {
guard let imageData = image.jpegData(compressionQuality: 0.5) else {
print("Could not get JPEG representation of UIImage")
return
}
AF.upload(
multipartFormData: { multipartFormData in
multipartFormData.append(imageData,
withName: "imagefile",
fileName: "image.jpg",
mimeType: "image/jpeg")
},
to: "http://website.com/upload.php", usingThreshold: UInt64.init(), method: .post)
.uploadProgress { progress in
progressCompletion(Float(progress.fractionCompleted))
}
.response { response in
debugPrint(response)
}
}
@IBAction func getStartedBtnClicked(_ sender: Any) {
upload(
image: UIImage(named: "uploadFile.png")!,
progressCompletion: { [weak self] percent in
guard let _ = self else {
return
}
print("Status: \(percent)")
},
completion: { [weak self] result in
guard let _ = self else {
return
}
})
}
Status: 1.0
...
[Data]: 19034 bytes
[Network Duration]: 0.9285140037536621s
[Serialization Duration]: 0.0s
[Result]: success(Optional(19034 bytes))
Status: 1.0
...
[Data]: None
[Network Duration]: 0.3820209503173828s
[Serialization Duration]: 0.0s
[Result]: success(nil)
if let fileURL = Bundle.main.url(forResource: "uploadFile", withExtension: "png") {
AF.upload(fileURL, to: "http://website.com/upload.php").responseJSON { response in
debugPrint(response)
}
}
[Request Body]:
None
[Response]:
[Status Code]: 200
[Headers]:
Connection: Upgrade, Keep-Alive
Content-Length: 0
Content-Type: text/html; charset=UTF-8
Date: Wed, 18 Dec 2019 06:19:32 GMT
Keep-Alive: timeout=5
Server: Apache
Upgrade: h2,h2c
Vary: User-Agent
X-Powered-By: PHP/7.2.20
[Response Body]:
None
[Data]: None
[Network Duration]: 0.33376002311706543s
[Serialization Duration]: 0.0014129877090454102s
[Result]: failure(Alamofire.AFError.responseSerializationFailed(reason: Alamofire.AFError.ResponseSerializationFailureReason.inputDataNilOrZeroLength))
<?php
if(isset($_FILES['image'])){
$errors= array();
$file_name = $_FILES['image']['name'];
$file_size =$_FILES['image']['size'];
$file_tmp =$_FILES['image']['tmp_name'];
$file_type=$_FILES['image']['type'];
$file_ext=strtolower(end(explode('.',$_FILES['image']['name'])));
$extensions= array("jpeg","jpg","png");
if(in_array($file_ext,$extensions)=== false){
$errors[]="extension not allowed, please choose a JPEG or PNG file.";
}
if($file_size > 2097152){
$errors[]='File size must be excately 2 MB';
}
if(empty($errors)==true){
move_uploaded_file($file_tmp,"images/".$file_name);
echo "Success";
}else{
print_r($errors);
}
}
?>
<html>
<body>
<form action="" method="POST" enctype="multipart/form-data">
<input type="file" name="image" />
<input type="submit"/>
</form>
</body>
</html>
对于我的自定义网站upload.php,结果是:
<?php
if(isset($_FILES['image'])){
$errors= array();
$file_name = $_FILES['image']['name'];
$file_size =$_FILES['image']['size'];
$file_tmp =$_FILES['image']['tmp_name'];
$file_type=$_FILES['image']['type'];
$file_ext=strtolower(end(explode('.',$_FILES['image']['name'])));
$extensions= array("jpeg","jpg","png");
if(in_array($file_ext,$extensions)===false){
$errors[]="extension not allowed, please choose a JPEG or PNG file.";
}
if($file_size > 2097152){
$errors[]='File size must be excately 2 MB';
}
if(empty($errors)==true){
move_uploaded_file($file_tmp,"images/".$file_name);
echo "Success";
}else{
print_r($errors);
}
}
?>
func upload(image: UIImage,
progressCompletion: @escaping (_ percent: Float) -> Void,
completion: @escaping (_ result: Bool) -> Void) {
guard let imageData = image.jpegData(compressionQuality: 0.5) else {
print("Could not get JPEG representation of UIImage")
return
}
AF.upload(
multipartFormData: { multipartFormData in
multipartFormData.append(imageData,
withName: "imagefile",
fileName: "image.jpg",
mimeType: "image/jpeg")
},
to: "http://website.com/upload.php", usingThreshold: UInt64.init(), method: .post)
.uploadProgress { progress in
progressCompletion(Float(progress.fractionCompleted))
}
.response { response in
debugPrint(response)
}
}
@IBAction func getStartedBtnClicked(_ sender: Any) {
upload(
image: UIImage(named: "uploadFile.png")!,
progressCompletion: { [weak self] percent in
guard let _ = self else {
return
}
print("Status: \(percent)")
},
completion: { [weak self] result in
guard let _ = self else {
return
}
})
}
Status: 1.0
...
[Data]: 19034 bytes
[Network Duration]: 0.9285140037536621s
[Serialization Duration]: 0.0s
[Result]: success(Optional(19034 bytes))
Status: 1.0
...
[Data]: None
[Network Duration]: 0.3820209503173828s
[Serialization Duration]: 0.0s
[Result]: success(nil)
if let fileURL = Bundle.main.url(forResource: "uploadFile", withExtension: "png") {
AF.upload(fileURL, to: "http://website.com/upload.php").responseJSON { response in
debugPrint(response)
}
}
[Request Body]:
None
[Response]:
[Status Code]: 200
[Headers]:
Connection: Upgrade, Keep-Alive
Content-Length: 0
Content-Type: text/html; charset=UTF-8
Date: Wed, 18 Dec 2019 06:19:32 GMT
Keep-Alive: timeout=5
Server: Apache
Upgrade: h2,h2c
Vary: User-Agent
X-Powered-By: PHP/7.2.20
[Response Body]:
None
[Data]: None
[Network Duration]: 0.33376002311706543s
[Serialization Duration]: 0.0014129877090454102s
[Result]: failure(Alamofire.AFError.responseSerializationFailed(reason: Alamofire.AFError.ResponseSerializationFailureReason.inputDataNilOrZeroLength))
<?php
if(isset($_FILES['image'])){
$errors= array();
$file_name = $_FILES['image']['name'];
$file_size =$_FILES['image']['size'];
$file_tmp =$_FILES['image']['tmp_name'];
$file_type=$_FILES['image']['type'];
$file_ext=strtolower(end(explode('.',$_FILES['image']['name'])));
$extensions= array("jpeg","jpg","png");
if(in_array($file_ext,$extensions)=== false){
$errors[]="extension not allowed, please choose a JPEG or PNG file.";
}
if($file_size > 2097152){
$errors[]='File size must be excately 2 MB';
}
if(empty($errors)==true){
move_uploaded_file($file_tmp,"images/".$file_name);
echo "Success";
}else{
print_r($errors);
}
}
?>
<html>
<body>
<form action="" method="POST" enctype="multipart/form-data">
<input type="file" name="image" />
<input type="submit"/>
</form>
</body>
</html>
即使是阿拉莫菲尔最简单的区块:
<?php
if(isset($_FILES['image'])){
$errors= array();
$file_name = $_FILES['image']['name'];
$file_size =$_FILES['image']['size'];
$file_tmp =$_FILES['image']['tmp_name'];
$file_type=$_FILES['image']['type'];
$file_ext=strtolower(end(explode('.',$_FILES['image']['name'])));
$extensions= array("jpeg","jpg","png");
if(in_array($file_ext,$extensions)===false){
$errors[]="extension not allowed, please choose a JPEG or PNG file.";
}
if($file_size > 2097152){
$errors[]='File size must be excately 2 MB';
}
if(empty($errors)==true){
move_uploaded_file($file_tmp,"images/".$file_name);
echo "Success";
}else{
print_r($errors);
}
}
?>
func upload(image: UIImage,
progressCompletion: @escaping (_ percent: Float) -> Void,
completion: @escaping (_ result: Bool) -> Void) {
guard let imageData = image.jpegData(compressionQuality: 0.5) else {
print("Could not get JPEG representation of UIImage")
return
}
AF.upload(
multipartFormData: { multipartFormData in
multipartFormData.append(imageData,
withName: "imagefile",
fileName: "image.jpg",
mimeType: "image/jpeg")
},
to: "http://website.com/upload.php", usingThreshold: UInt64.init(), method: .post)
.uploadProgress { progress in
progressCompletion(Float(progress.fractionCompleted))
}
.response { response in
debugPrint(response)
}
}
@IBAction func getStartedBtnClicked(_ sender: Any) {
upload(
image: UIImage(named: "uploadFile.png")!,
progressCompletion: { [weak self] percent in
guard let _ = self else {
return
}
print("Status: \(percent)")
},
completion: { [weak self] result in
guard let _ = self else {
return
}
})
}
Status: 1.0
...
[Data]: 19034 bytes
[Network Duration]: 0.9285140037536621s
[Serialization Duration]: 0.0s
[Result]: success(Optional(19034 bytes))
Status: 1.0
...
[Data]: None
[Network Duration]: 0.3820209503173828s
[Serialization Duration]: 0.0s
[Result]: success(nil)
if let fileURL = Bundle.main.url(forResource: "uploadFile", withExtension: "png") {
AF.upload(fileURL, to: "http://website.com/upload.php").responseJSON { response in
debugPrint(response)
}
}
[Request Body]:
None
[Response]:
[Status Code]: 200
[Headers]:
Connection: Upgrade, Keep-Alive
Content-Length: 0
Content-Type: text/html; charset=UTF-8
Date: Wed, 18 Dec 2019 06:19:32 GMT
Keep-Alive: timeout=5
Server: Apache
Upgrade: h2,h2c
Vary: User-Agent
X-Powered-By: PHP/7.2.20
[Response Body]:
None
[Data]: None
[Network Duration]: 0.33376002311706543s
[Serialization Duration]: 0.0014129877090454102s
[Result]: failure(Alamofire.AFError.responseSerializationFailed(reason: Alamofire.AFError.ResponseSerializationFailureReason.inputDataNilOrZeroLength))
<?php
if(isset($_FILES['image'])){
$errors= array();
$file_name = $_FILES['image']['name'];
$file_size =$_FILES['image']['size'];
$file_tmp =$_FILES['image']['tmp_name'];
$file_type=$_FILES['image']['type'];
$file_ext=strtolower(end(explode('.',$_FILES['image']['name'])));
$extensions= array("jpeg","jpg","png");
if(in_array($file_ext,$extensions)=== false){
$errors[]="extension not allowed, please choose a JPEG or PNG file.";
}
if($file_size > 2097152){
$errors[]='File size must be excately 2 MB';
}
if(empty($errors)==true){
move_uploaded_file($file_tmp,"images/".$file_name);
echo "Success";
}else{
print_r($errors);
}
}
?>
<html>
<body>
<form action="" method="POST" enctype="multipart/form-data">
<input type="file" name="image" />
<input type="submit"/>
</form>
</body>
</html>
我收到inputDataNilOrZeroLength错误:
<?php
if(isset($_FILES['image'])){
$errors= array();
$file_name = $_FILES['image']['name'];
$file_size =$_FILES['image']['size'];
$file_tmp =$_FILES['image']['tmp_name'];
$file_type=$_FILES['image']['type'];
$file_ext=strtolower(end(explode('.',$_FILES['image']['name'])));
$extensions= array("jpeg","jpg","png");
if(in_array($file_ext,$extensions)===false){
$errors[]="extension not allowed, please choose a JPEG or PNG file.";
}
if($file_size > 2097152){
$errors[]='File size must be excately 2 MB';
}
if(empty($errors)==true){
move_uploaded_file($file_tmp,"images/".$file_name);
echo "Success";
}else{
print_r($errors);
}
}
?>
func upload(image: UIImage,
progressCompletion: @escaping (_ percent: Float) -> Void,
completion: @escaping (_ result: Bool) -> Void) {
guard let imageData = image.jpegData(compressionQuality: 0.5) else {
print("Could not get JPEG representation of UIImage")
return
}
AF.upload(
multipartFormData: { multipartFormData in
multipartFormData.append(imageData,
withName: "imagefile",
fileName: "image.jpg",
mimeType: "image/jpeg")
},
to: "http://website.com/upload.php", usingThreshold: UInt64.init(), method: .post)
.uploadProgress { progress in
progressCompletion(Float(progress.fractionCompleted))
}
.response { response in
debugPrint(response)
}
}
@IBAction func getStartedBtnClicked(_ sender: Any) {
upload(
image: UIImage(named: "uploadFile.png")!,
progressCompletion: { [weak self] percent in
guard let _ = self else {
return
}
print("Status: \(percent)")
},
completion: { [weak self] result in
guard let _ = self else {
return
}
})
}
Status: 1.0
...
[Data]: 19034 bytes
[Network Duration]: 0.9285140037536621s
[Serialization Duration]: 0.0s
[Result]: success(Optional(19034 bytes))
Status: 1.0
...
[Data]: None
[Network Duration]: 0.3820209503173828s
[Serialization Duration]: 0.0s
[Result]: success(nil)
if let fileURL = Bundle.main.url(forResource: "uploadFile", withExtension: "png") {
AF.upload(fileURL, to: "http://website.com/upload.php").responseJSON { response in
debugPrint(response)
}
}
[Request Body]:
None
[Response]:
[Status Code]: 200
[Headers]:
Connection: Upgrade, Keep-Alive
Content-Length: 0
Content-Type: text/html; charset=UTF-8
Date: Wed, 18 Dec 2019 06:19:32 GMT
Keep-Alive: timeout=5
Server: Apache
Upgrade: h2,h2c
Vary: User-Agent
X-Powered-By: PHP/7.2.20
[Response Body]:
None
[Data]: None
[Network Duration]: 0.33376002311706543s
[Serialization Duration]: 0.0014129877090454102s
[Result]: failure(Alamofire.AFError.responseSerializationFailed(reason: Alamofire.AFError.ResponseSerializationFailureReason.inputDataNilOrZeroLength))
<?php
if(isset($_FILES['image'])){
$errors= array();
$file_name = $_FILES['image']['name'];
$file_size =$_FILES['image']['size'];
$file_tmp =$_FILES['image']['tmp_name'];
$file_type=$_FILES['image']['type'];
$file_ext=strtolower(end(explode('.',$_FILES['image']['name'])));
$extensions= array("jpeg","jpg","png");
if(in_array($file_ext,$extensions)=== false){
$errors[]="extension not allowed, please choose a JPEG or PNG file.";
}
if($file_size > 2097152){
$errors[]='File size must be excately 2 MB';
}
if(empty($errors)==true){
move_uploaded_file($file_tmp,"images/".$file_name);
echo "Success";
}else{
print_r($errors);
}
}
?>
<html>
<body>
<form action="" method="POST" enctype="multipart/form-data">
<input type="file" name="image" />
<input type="submit"/>
</form>
</body>
</html>
在upload.php的顶部,可以从web上使用以下页面:
<?php
if(isset($_FILES['image'])){
$errors= array();
$file_name = $_FILES['image']['name'];
$file_size =$_FILES['image']['size'];
$file_tmp =$_FILES['image']['tmp_name'];
$file_type=$_FILES['image']['type'];
$file_ext=strtolower(end(explode('.',$_FILES['image']['name'])));
$extensions= array("jpeg","jpg","png");
if(in_array($file_ext,$extensions)===false){
$errors[]="extension not allowed, please choose a JPEG or PNG file.";
}
if($file_size > 2097152){
$errors[]='File size must be excately 2 MB';
}
if(empty($errors)==true){
move_uploaded_file($file_tmp,"images/".$file_name);
echo "Success";
}else{
print_r($errors);
}
}
?>
func upload(image: UIImage,
progressCompletion: @escaping (_ percent: Float) -> Void,
completion: @escaping (_ result: Bool) -> Void) {
guard let imageData = image.jpegData(compressionQuality: 0.5) else {
print("Could not get JPEG representation of UIImage")
return
}
AF.upload(
multipartFormData: { multipartFormData in
multipartFormData.append(imageData,
withName: "imagefile",
fileName: "image.jpg",
mimeType: "image/jpeg")
},
to: "http://website.com/upload.php", usingThreshold: UInt64.init(), method: .post)
.uploadProgress { progress in
progressCompletion(Float(progress.fractionCompleted))
}
.response { response in
debugPrint(response)
}
}
@IBAction func getStartedBtnClicked(_ sender: Any) {
upload(
image: UIImage(named: "uploadFile.png")!,
progressCompletion: { [weak self] percent in
guard let _ = self else {
return
}
print("Status: \(percent)")
},
completion: { [weak self] result in
guard let _ = self else {
return
}
})
}
Status: 1.0
...
[Data]: 19034 bytes
[Network Duration]: 0.9285140037536621s
[Serialization Duration]: 0.0s
[Result]: success(Optional(19034 bytes))
Status: 1.0
...
[Data]: None
[Network Duration]: 0.3820209503173828s
[Serialization Duration]: 0.0s
[Result]: success(nil)
if let fileURL = Bundle.main.url(forResource: "uploadFile", withExtension: "png") {
AF.upload(fileURL, to: "http://website.com/upload.php").responseJSON { response in
debugPrint(response)
}
}
[Request Body]:
None
[Response]:
[Status Code]: 200
[Headers]:
Connection: Upgrade, Keep-Alive
Content-Length: 0
Content-Type: text/html; charset=UTF-8
Date: Wed, 18 Dec 2019 06:19:32 GMT
Keep-Alive: timeout=5
Server: Apache
Upgrade: h2,h2c
Vary: User-Agent
X-Powered-By: PHP/7.2.20
[Response Body]:
None
[Data]: None
[Network Duration]: 0.33376002311706543s
[Serialization Duration]: 0.0014129877090454102s
[Result]: failure(Alamofire.AFError.responseSerializationFailed(reason: Alamofire.AFError.ResponseSerializationFailureReason.inputDataNilOrZeroLength))
<?php
if(isset($_FILES['image'])){
$errors= array();
$file_name = $_FILES['image']['name'];
$file_size =$_FILES['image']['size'];
$file_tmp =$_FILES['image']['tmp_name'];
$file_type=$_FILES['image']['type'];
$file_ext=strtolower(end(explode('.',$_FILES['image']['name'])));
$extensions= array("jpeg","jpg","png");
if(in_array($file_ext,$extensions)=== false){
$errors[]="extension not allowed, please choose a JPEG or PNG file.";
}
if($file_size > 2097152){
$errors[]='File size must be excately 2 MB';
}
if(empty($errors)==true){
move_uploaded_file($file_tmp,"images/".$file_name);
echo "Success";
}else{
print_r($errors);
}
}
?>
<html>
<body>
<form action="" method="POST" enctype="multipart/form-data">
<input type="file" name="image" />
<input type="submit"/>
</form>
</body>
</html>
即使是简单的文件上传,我也找不到办法。我错过了什么?如果有人解释一下就好了
稍后,我应该将其配置为上传视频文件。对此有任何配置建议吗?您在服务器中查找的文件名是
$\u FILES['image']
,随请求发送的文件名是imagefile
。请尝试更改multipartFormData
的附件,如下所示
multipartFormData.append(imageData,
withName: "image",
fileName: "image.jpg",
mimeType: "image/jpeg")
在multipartFormData中,您可以尝试将名为“imagefile”的
文件更改为名为“image”的文件吗。我想问更多的细节。我的上传文件夹的CHMOD权限为“775”。这是合乎逻辑的,还是我应该采取另一种安全措施?我将采取“https”,另一个行动等,我还可以如何配置视频文件呢?如果你有关于他们的知识,请分享详细的答案。我会很感激的。我不是专家:),就我所知,775是一个理想的许可证。您还可以通过只允许经过身份验证的用户访问上传的文件来增加额外的安全性,并阻止通过URL直接访问文件。我使用multipart,忘记使用Name重命名:“image”,您节省了我的时间非常感谢