关于php:在Codeigniter中多图像上传中的文件事务处理

File transaction handling in multiple image upload in codeigniter

我正在CodeIgniter中上载多个图像,并且我想创建一个文件事务处理系统来上载图像。
问题是当我们在图像之间选择任何非图像文件时,CodeIgniter将无法回滚任何系统以删除上载的图像。
我应该怎么做才能管理此图像上传?

在允许的尺寸图像之间上载任何较大尺寸的图像时,也会发生相同的问题。 CI会上传一些文件,并且当更大的图像出现时,CI会给出一个错误,但是直到之前的图像将被上传为止。

最终目标是,如果在文件上传之间发生任何错误,则所有过程都将回滚。

那么我如何像在MySQL中处理事务一样管理该文件事务


使您的图像上载功能足以处理它。尝试这样的事情:

1
2
3
4
5
6
7
$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