简体   繁体   English

Codeigniter中多图像上传中的文件事务处理

[英]File transaction handling in multiple image upload in codeigniter

I am doing multiple image upload in CodeIgniter and I want to create a file transaction handling system to upload images. 我正在CodeIgniter中进行多个图像上传,我想创建一个文件事务处理系统来上传图像。 The problem is when we select any nonimage file between the images then CodeIgniter can not have any system to rollback to remove the uploaded images. 问题是,当我们在图像之间选择任何非图像文件时,CodeIgniter将无法回滚任何系统以删除上载的图像。 what should I do to manage this image upload? 我应该怎么做才能管理此图像上传?

the same problem occurs when any bigger size image uploaded between the allowed size images. 当在允许的尺寸图像之间上载任何较大尺寸的图像时,也会发生相同的问题。 CI upload some files and when the bigger image comes then CI gives an error but till the previous images will get uploaded. CI会上传一些文件,并且当更大的图像出现时,CI会给出一个错误,但直到之前的图像将被上传为止。

The final goal is that if any error occurs between file upload then all the process will get rollback. 最终目标是,如果文件上传之间发生任何错误,则所有过程都将回滚。

So how can I manage this file transaction like we handle the transaction in the MySQL 因此,如何像在MySQL中处理事务一样管理该文件事务

Make your image upload function capable enough to handle it. 使图像上载功能足以处理它。 Try something like this: 尝试这样的事情:

$fileNames = array();
// To hold the the file names of all the files available in $_FILES

$fileStatus = array();
// hold  the file name wise status i.e. TRUE/FALSE like filename => status

// Put a check to ensure all files have a TRUE status, if any one fails then unlink (delete) all the uploaded file for the current session

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM