Table of Contents
上传表单
上传操作
上传参数
上传文件信息
单文件上传
上传文件的命名规则
子目录保存
上传驱动
Home Database Mysql Tutorial ThinkPHP3.2文件上传

ThinkPHP3.2文件上传

Jun 07, 2016 pm 03:48 PM
thinkphp3.2 upload document form

上传表单 在ThinkPHP中使用上传功能无需进行特别处理。例如,下面是一个带有附件上传的表单提交: form action = __URL__/upload enctype = multipart/form-data method = post input type = text name = name / input type = file name = photo / input typ

上传表单

在ThinkPHP中使用上传功能无需进行特别处理。例如,下面是一个带有附件上传的表单提交:

<ol>
<li><code><span><form>
<span>action</span><span>=</span><span>"__URL__/upload"</span><span>enctype</span><span>=</span><span>"multipart/form-data"</span><span>method</span><span>=</span><span>"post"</span><span>></span>
</form></span></code></li>
<li><code><span><input><span>type</span><span>=</span><span>"text"</span><span>name</span><span>=</span><span>"name"</span><span>/></span></span></code></li>
<li><code><span><input><span>type</span><span>=</span><span>"file"</span><span>name</span><span>=</span><span>"photo"</span><span>/></span></span></code></li>
<li><code><span><input><span>type</span><span>=</span><span>"submit"</span><span>value</span><span>=</span><span>"提交"</span><span>></span></span></code></li>
<li><code></code></li>
</ol>
Copy after login

注意,要使用上传功能 你的表单需要设置 enctype="multipart/form-data"

多文件上传支持

如果需要使用多个文件上传,只需要修改表单,把

<ol><li><code><span><input><span>type</span><span>=</span><span>'file'</span><span>name</span><span>=</span><span>'photo'</span><span>></span></span></code></li></ol>
Copy after login

改为

<ol>
<li><code><span><input><span>type</span><span>=</span><span>'file'</span><span>name</span><span>=</span><span>'photo1'</span><span>></span></span></code></li>
<li><code><span><input><span>type</span><span>=</span><span>'file'</span><span>name</span><span>=</span><span>'photo2'</span><span>></span></span></code></li>
<li><code><span><input><span>type</span><span>=</span><span>'file'</span><span>name</span><span>=</span><span>'photo3'</span><span>></span></span></code></li>
</ol>
Copy after login

或者

<ol>
<li><code><span><input><span>type</span><span>=</span><span>'file'</span><span>name</span><span>=</span><span>'photo[]'</span><span>></span></span></code></li>
<li><code><span><input><span>type</span><span>=</span><span>'file'</span><span>name</span><span>=</span><span>'photo[]'</span><span>></span></span></code></li>
<li><code><span><input><span>type</span><span>=</span><span>'file'</span><span>name</span><span>=</span><span>'photo[]'</span><span>></span></span></code></li>
</ol>
Copy after login

两种方式的多附件上传系统的文件上传类都可以自动识别。

上传操作

ThinkPHP文件上传操作使用Think\Upload类,假设前面的表单提交到当前控制器的upload方法,我们来看下upload方法的实现代码:

<ol>
<li><code><span>public</span><span>function</span><span> upload</span><span>(){</span></code></li>
<li><code><span>    $upload </span><span>=</span><span>new</span><span> \Think\Upload</span><span>();</span><span>// 实例化上传类</span></code></li>
<li><code><span>    $upload</span><span>-></span><span>maxSize   </span><span>=</span><span>3145728</span><span>;</span><span>// 设置附件上传大小</span></code></li>
<li><code><span>    $upload</span><span>-></span><span>exts      </span><span>=</span><span>     array</span><span>(</span><span>'jpg'</span><span>,</span><span>'gif'</span><span>,</span><span>'png'</span><span>,</span><span>'jpeg'</span><span>);</span><span>// 设置附件上传类型</span></code></li>
<li><code><span>    $upload</span><span>-></span><span>rootPath  </span><span>=</span><span>'./Uploads/'</span><span>;</span><span>// 设置附件上传根目录</span></code></li>
<li><code><span>    $upload</span><span>-></span><span>savePath  </span><span>=</span><span>''</span><span>;</span><span>// 设置附件上传(子)目录</span></code></li>
<li><code><span>// 上传文件 </span></code></li>
<li><code><span>    $info   </span><span>=</span><span>   $upload</span><span>-></span><span>upload</span><span>();</span></code></li>
<li><code><span>if</span><span>(!</span><span>$info</span><span>)</span><span>{</span><span>// 上传错误提示错误信息</span></code></li>
<li><code><span>        $this</span><span>-></span><span>error</span><span>(</span><span>$upload</span><span>-></span><span>getError</span><span>());</span></code></li>
<li><code><span>}</span><span>else</span><span>{</span><span>// 上传成功</span></code></li>
<li><code><span>        $this</span><span>-></span><span>success</span><span>(</span><span>'上传成功!'</span><span>);</span></code></li>
<li><code><span>}</span></code></li>
<li><code>}</code></li>
</ol>
Copy after login

上传类对图片文件的上传安全做了支持,如果企图上传非法的图像文件,系统会提示 非法图像文件。 为了更好的使用上传功能,建议你的服务器开启finfo模块支持

上传参数

在上传操作之前,我们可以对上传的属性进行一些设置,Upload类支持的属性设置包括:

属性 描述
maxSize 文件上传的最大文件大小(以字节为单位),0为不限大小
rootPath 文件上传保存的根路径
savePath 文件上传的保存路径(相对于根路径)
saveName 上传文件的保存规则,支持数组和字符串方式定义
saveExt 上传文件的保存后缀,不设置的话使用原文件后缀
replace 存在同名文件是否是覆盖,默认为false
exts 允许上传的文件后缀(留空为不限制),使用数组或者逗号分隔的字符串设置,默认为空
mimes 允许上传的文件类型(留空为不限制),使用数组或者逗号分隔的字符串设置,默认为空
autoSub 自动使用子目录保存上传文件 默认为true
subName 子目录创建方式,采用数组或者字符串方式定义
hash 是否生成文件的hash编码 默认为true
callback 检测文件是否存在回调,如果存在返回文件信息数组

上面的属性可以通过两种方式传入:

实例化传入

我们可以在实例化的时候直接传入参数数组,例如:

<ol>
<li><code><span>$config </span><span>=</span><span> array</span><span>(</span></code></li>
<li><code><span>'maxSize'</span><span>=></span><span>3145728</span><span>,</span></code></li>
<li><code><span>'rootPath'</span><span>=></span><span>'./Uploads/'</span><span>,</span></code></li>
<li><code><span>'savePath'</span><span>=></span><span>''</span><span>,</span></code></li>
<li><code><span>'saveName'</span><span>=></span><span>    array</span><span>(</span><span>'uniqid'</span><span>,</span><span>''</span><span>),</span></code></li>
<li><code><span>'exts'</span><span>=></span><span>    array</span><span>(</span><span>'jpg'</span><span>,</span><span>'gif'</span><span>,</span><span>'png'</span><span>,</span><span>'jpeg'</span><span>),</span></code></li>
<li><code><span>'autoSub'</span><span>=></span><span>true</span><span>,</span></code></li>
<li><code><span>'subName'</span><span>=></span><span>    array</span><span>(</span><span>'date'</span><span>,</span><span>'Ymd'</span><span>),</span></code></li>
<li><code>);</code></li>
<li><code><span>$upload </span><span>=</span><span>new</span><span> \Think\Upload</span><span>(</span><span>$config</span><span>);</span><span>// 实例化上传类</span></code></li>
</ol>
Copy after login

关于saveName和subName的使用后面我们会有详细的描述。

动态赋值

支持在实例化后动态赋值上传参数,例如:

<ol>
<li><code><span>$upload </span><span>=</span><span>new</span><span> \Think\Upload</span><span>();</span><span>// 实例化上传类</span></code></li>
<li><code><span>$upload</span><span>-></span><span>maxSize </span><span>=</span><span>3145728</span><span>;</span></code></li>
<li><code><span>$upload</span><span>-></span><span>rootPath </span><span>=</span><span>'./Uploads/'</span><span>;</span></code></li>
<li><code><span>$upload</span><span>-></span><span>savePath </span><span>=</span><span>''</span><span>;</span></code></li>
<li><code><span>$upload</span><span>-></span><span>saveName </span><span>=</span><span> array</span><span>(</span><span>'uniqid'</span><span>,</span><span>''</span><span>);</span></code></li>
<li><code><span>$upload</span><span>-></span><span>exts     </span><span>=</span><span> array</span><span>(</span><span>'jpg'</span><span>,</span><span>'gif'</span><span>,</span><span>'png'</span><span>,</span><span>'jpeg'</span><span>);</span></code></li>
<li><code><span>$upload</span><span>-></span><span>autoSub  </span><span>=</span><span>true</span><span>;</span></code></li>
<li><code><span>$upload</span><span>-></span><span>subName  </span><span>=</span><span> array</span><span>(</span><span>'date'</span><span>,</span><span>'Ymd'</span><span>);</span></code></li>
</ol>
Copy after login

上面的设置和实例化传入的效果是一致的。

上传文件信息

设置好上传的参数后,就可以调用Think\Upload类的upload方法进行附件上传,如果失败,返回false,并且用getError方法获取错误提示信息;如果上传成功,就返回成功上传的文件信息数组。

<ol>
<li><code><span>$upload </span><span>=</span><span>new</span><span> \Think\Upload</span><span>();</span><span>// 实例化上传类</span></code></li>
<li><code><span>$upload</span><span>-></span><span>maxSize   </span><span>=</span><span>3145728</span><span>;</span><span>// 设置附件上传大小</span></code></li>
<li><code><span>$upload</span><span>-></span><span>exts      </span><span>=</span><span>     array</span><span>(</span><span>'jpg'</span><span>,</span><span>'gif'</span><span>,</span><span>'png'</span><span>,</span><span>'jpeg'</span><span>);</span><span>// 设置附件上传类型</span></code></li>
<li><code><span>$upload</span><span>-></span><span>rootPath  </span><span>=</span><span>'./Uploads/'</span><span>;</span><span>// 设置附件上传根目录</span></code></li>
<li><code><span>$upload</span><span>-></span><span>savePath  </span><span>=</span><span>''</span><span>;</span><span>// 设置附件上传(子)目录</span></code></li>
<li><code>// 上传文件 </code></li>
<li><code><span>$info   </span><span>=</span><span>   $upload</span><span>-></span><span>upload</span><span>();</span></code></li>
<li><code><span>if</span><span>(!</span><span>$info</span><span>)</span><span>{</span><span>// 上传错误提示错误信息</span></code></li>
<li><code><span>    $this</span><span>-></span><span>error</span><span>(</span><span>$upload</span><span>-></span><span>getError</span><span>());</span></code></li>
<li><code><span>}</span><span>else</span><span>{</span><span>// 上传成功 获取上传文件信息</span></code></li>
<li><code><span>foreach</span><span>(</span><span>$info </span><span>as</span><span> $file</span><span>){</span></code></li>
<li><code><span>        echo $file</span><span>[</span><span>'savepath'</span><span>].</span><span>$file</span><span>[</span><span>'savename'</span><span>];</span></code></li>
<li><code><span>}</span></code></li>
<li><code>}</code></li>
</ol>
Copy after login

每个文件信息又是一个记录了下面信息的数组,包括:

属性 描述
key 附件上传的表单名称
savepath 上传文件的保存路径
name 上传文件的原始名称
savename 上传文件的保存名称
size 上传文件的大小
type 上传文件的MIME类型
ext 上传文件的后缀类型
md5 上传文件的md5哈希验证字符串 仅当hash设置开启后有效
sha1 上传文件的sha1哈希验证字符串 仅当hash设置开启后有效

文件上传成功后,就可以使用这些文件信息来进行其他的数据操作,例如保存到当前数据表或者单独的附件数据表。

例如,下面表示把上传信息保存到数据表的字段:

<ol>
<li><code><span>$model </span><span>=</span><span> M</span><span>(</span><span>'Photo'</span><span>);</span></code></li>
<li><code>// 取得成功上传的文件信息</code></li>
<li><code><span>$info </span><span>=</span><span> $upload</span><span>-></span><span>upload</span><span>();</span></code></li>
<li><code>// 保存当前数据对象</code></li>
<li><code><span>$data</span><span>[</span><span>'photo'</span><span>]</span><span>=</span><span> $info</span><span>[</span><span>0</span><span>][</span><span>'savename'</span><span>];</span></code></li>
<li><code><span>$data</span><span>[</span><span>'create_time'</span><span>]</span><span>=</span><span> NOW_TIME</span><span>;</span></code></li>
<li><code><span>$model</span><span>-></span><span>add</span><span>(</span><span>$data</span><span>);</span></code></li>
</ol>
Copy after login

单文件上传

upload方法支持多文件上传,有时候,我们只需要上传一个文件,就可以使用Upload类提供的uploadOne方法上传单个文件,例如:

<ol>
<li><code><span>public</span><span>function</span><span> upload</span><span>(){</span></code></li>
<li><code><span>    $upload </span><span>=</span><span>new</span><span> \Think\Upload</span><span>();</span><span>// 实例化上传类</span></code></li>
<li><code><span>    $upload</span><span>-></span><span>maxSize   </span><span>=</span><span>3145728</span><span>;</span><span>// 设置附件上传大小</span></code></li>
<li><code><span>    $upload</span><span>-></span><span>exts      </span><span>=</span><span>     array</span><span>(</span><span>'jpg'</span><span>,</span><span>'gif'</span><span>,</span><span>'png'</span><span>,</span><span>'jpeg'</span><span>);</span><span>// 设置附件上传类型</span></code></li>
<li><code><span>    $upload</span><span>-></span><span>rootPath  </span><span>=</span><span>'./Uploads/'</span><span>;</span><span>// 设置附件上传根目录</span></code></li>
<li><code><span>// 上传单个文件 </span></code></li>
<li><code><span>    $info   </span><span>=</span><span>   $upload</span><span>-></span><span>uploadOne</span><span>(</span><span>$_FILES</span><span>[</span><span>'photo1'</span><span>]);</span></code></li>
<li><code><span>if</span><span>(!</span><span>$info</span><span>)</span><span>{</span><span>// 上传错误提示错误信息</span></code></li>
<li><code><span>        $this</span><span>-></span><span>error</span><span>(</span><span>$upload</span><span>-></span><span>getError</span><span>());</span></code></li>
<li><code><span>}</span><span>else</span><span>{</span><span>// 上传成功 获取上传文件信息</span></code></li>
<li><code><span>         echo $info</span><span>[</span><span>'savepath'</span><span>].</span><span>$info</span><span>[</span><span>'savename'</span><span>];</span></code></li>
<li><code><span>}</span></code></li>
<li><code>}</code></li>
</ol>
Copy after login

uploadOne方法上传成功后返回的文件信息和upload方法的区别是只有单个文件信息的一维数组。

上传文件的命名规则

上传文件的命名规则(saveName)用于确保文件不会产生冲突或者覆盖的情况。命名规则的定义可以根据你的业务逻辑来调整,不是固定的。例如, 如果你采用时间戳的方式来定义命名规范,那么在同时上传多个文件的时候可能产生冲突(因为同一秒内可以上传多个文件),因此你需要根据你的业务需求来设置 合适的上传命名规则。这里顺便来说下saveName参数的具体用法。

一、采用函数方式

如果传入的字符串是一个函数名,那么表示采用函数动态生成上传文件名(不包括文件后缀),例如:

<ol>
<li><code>// 采用时间戳命名</code></li>
<li><code><span>$upload</span><span>-></span><span>saveName </span><span>=</span><span>'time'</span><span>;</span></code></li>
<li><code>// 采用GUID序列命名</code></li>
<li><code><span>$upload</span><span>-></span><span>saveName </span><span>=</span><span>'com_create_guid'</span><span>;</span></code></li>
</ol>
Copy after login

也可以采用用户自定义函数

<ol>
<li><code>// 采用自定义函数命名</code></li>
<li><code><span>$upload</span><span>-></span><span>saveName </span><span>=</span><span>'myfun'</span><span>;</span></code></li>
</ol>
Copy after login

默认的命名规则设置是采用uniqid函数生成一个唯一的字符串序列。

saveName的值支持数组和字符串两种方式,如果是只有一个参数或者没有参数的函数,直接使用字符串设置即可,如果需要传入额外的参数,可以使用数组方式,例如:

<ol>
<li><code>// 采用date函数生成命名规则 传入Y-m-d参数</code></li>
<li><code><span>$upload</span><span>-></span><span>saveName </span><span>=</span><span> array</span><span>(</span><span>'date'</span><span>,</span><span>'Y-m-d'</span><span>);</span></code></li>
<li><code>// 如果有多个参数需要传入的话 可以使用数组</code></li>
<li><code><span>$upload</span><span>-></span><span>saveName </span><span>=</span><span> array</span><span>(</span><span>'myFun'</span><span>,</span><span>array</span><span>(</span><span>'__FILE__'</span><span>,</span><span>'val1'</span><span>,</span><span>'val2'</span><span>));</span></code></li>
</ol>
Copy after login

如果需要使用上传的原始文件名,可以采用__FILE__传入,所以上面的定义规则,最终的结果是 myFun('上传文件名','val1','val2')执行的结果。

二、直接设置上传文件名

如果传入的参数不是一个函数名,那么就会直接当做是上传文件名,例如:

<ol><li><code><span>$upload</span><span>-></span><span>saveName </span><span>=</span><span> time</span><span>().</span><span>'_'</span><span>.</span><span>mt_rand</span><span>();</span></code></li></ol>
Copy after login

表示上传的文件命名采用时间戳加一个随机数的组合字符串方式。

当然,如果觉得有必要,你还可以固定设置一个上传文件的命名规则,用于固定保存某个上传文件。

<ol><li><code><span>$upload</span><span>-></span><span>saveName </span><span>=</span><span>'ThinkPHP'</span><span>;</span></code></li></ol>
Copy after login

三、保持上传文件名不变

如果你想保持上传的文件名不变,那么只需要设置命名规范为空即可,例如:

<ol><li><code><span>$upload</span><span>-></span><span>saveName </span><span>=</span><span>''</span><span>;</span></code></li></ol>
Copy after login

一般来说不建议保持不变,因为会导致相同的文件名上传后被覆盖的情况。

子目录保存

saveName只是用于设置文件的保存规则,不涉及到目录,如果希望对上传的文件分子目录保存,可以设置autoSubsubName参数来完成,例如:

<ol>
<li><code>// 开启子目录保存 并以日期(格式为Ymd)为子目录</code></li>
<li><code><span>$upload</span><span>-></span><span>autoSub </span><span>=</span><span>true</span><span>;</span></code></li>
<li><code><span>$upload</span><span>-></span><span>subName </span><span>=</span><span> array</span><span>(</span><span>'date'</span><span>,</span><span>'Ymd'</span><span>);</span></code></li>
</ol>
Copy after login

可以使用自定义函数来保存,例如:

<ol>
<li><code>// 开启子目录保存 并调用自定义函数get_user_id生成子目录</code></li>
<li><code><span>$upload</span><span>-></span><span>autoSub </span><span>=</span><span>true</span><span>;</span></code></li>
<li><code><span>$upload</span><span>-></span><span>subName </span><span>=</span><span>'get_user_id'</span><span>;</span></code></li>
</ol>
Copy after login

和saveName参数一样,subName的定义可以采用数组和字符串的方式。

注意:如果get_user_id函数未定义的话,会直接以get_user_id字符串作为子目录的名称保存。

子目录保存和文件命名规则可以结合使用。

上传驱动

上传类可以支持不同的环境,通过相应的上传驱动来解决,默认情况下使用本地(Local)上传驱动,当然,你还可以设置当前默认的上传驱动类型,例如:

<ol>
<li><code><span>'FILE_UPLOAD_TYPE'</span><span>=></span><span>'Ftp'</span><span>,</span></code></li>
<li><code><span>'UPLOAD_TYPE_CONFIG'</span><span>=></span><span>    array</span><span>(</span></code></li>
<li><code><span>'host'</span><span>=></span><span>'192.168.1.200'</span><span>,</span><span>//服务器</span></code></li>
<li><code><span>'port'</span><span>=></span><span>21</span><span>,</span><span>//端口</span></code></li>
<li><code><span>'timeout'</span><span>=></span><span>90</span><span>,</span><span>//超时时间</span></code></li>
<li><code><span>'username'</span><span>=></span><span>'ftp_user'</span><span>,</span><span>//用户名</span></code></li>
<li><code><span>'password'</span><span>=></span><span>'ftp_pwd'</span><span>,</span><span>//密码 ),</span></code></li>
</ol>
Copy after login

表示当前使用Ftp作为上传类的驱动,上传的文件会通过FTP传到指定的远程服务器。

也可以在实例化上传类的时候指定,例如:

<ol>
<li><code><span>$config </span><span>=</span><span> array</span><span>(</span></code></li>
<li><code><span>'maxSize'</span><span>=</span><span>3145728</span><span>,</span></code></li>
<li><code><span>'rootPath'</span><span>=</span><span>'./Uploads/'</span><span>,</span></code></li>
<li><code><span>'savePath'</span><span>=</span><span>''</span><span>,</span></code></li>
<li><code><span>'saveName'</span><span>=</span><span>    array</span><span>(</span><span>'uniqid'</span><span>,</span><span>''</span><span>),</span></code></li>
<li><code><span>'exts'</span><span>=</span><span>    array</span><span>(</span><span>'jpg'</span><span>,</span><span>'gif'</span><span>,</span><span>'png'</span><span>,</span><span>'jpeg'</span><span>),</span></code></li>
<li><code><span>'autoSub'</span><span>=</span><span>true</span><span>,</span></code></li>
<li><code><span>'subName'</span><span>=</span><span>    array</span><span>(</span><span>'date'</span><span>,</span><span>'Ymd'</span><span>),</span></code></li>
<li><code>);</code></li>
<li><code><span>$ftpConfig     </span><span>=</span><span>    array</span><span>(</span></code></li>
<li><code><span>'host'</span><span>=></span><span>'192.168.1.200'</span><span>,</span><span>//服务器</span></code></li>
<li><code><span>'port'</span><span>=></span><span>21</span><span>,</span><span>//端口</span></code></li>
<li><code><span>'timeout'</span><span>=></span><span>90</span><span>,</span><span>//超时时间</span></code></li>
<li><code><span>'username'</span><span>=></span><span>'ftp_user'</span><span>,</span><span>//用户名</span></code></li>
<li><code><span>'password'</span><span>=></span><span>'ftp_pwd'</span><span>,</span><span>//密码 );</span></code></li>
<li> </li>
<li><code><span>$upload </span><span>=</span><span>new</span><span> \Think\Upload</span><span>(</span><span>$config</span><span>,</span><span>'Ftp'</span><span>,</span><span>$ftpConfig</span><span>);</span><span>// 实例化上传类</span></code></li>
</ol>
Copy after login
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Two Point Museum: All Exhibits And Where To Find Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to recover expired WeChat files? Can expired WeChat files be recovered? How to recover expired WeChat files? Can expired WeChat files be recovered? Feb 22, 2024 pm 02:46 PM

Open WeChat, select Settings in Me, select General and then select Storage Space, select Management in Storage Space, select the conversation in which you want to restore files and select the exclamation mark icon. Tutorial Applicable Model: iPhone13 System: iOS15.3 Version: WeChat 8.0.24 Analysis 1 First open WeChat and click the Settings option on the My page. 2 Then find and click General Options on the settings page. 3Then click Storage Space on the general page. 4 Next, click Manage on the storage space page. 5Finally, select the conversation in which you want to recover files and click the exclamation mark icon on the right. Supplement: WeChat files generally expire in a few days. If the file received by WeChat has not been clicked, the WeChat system will clear it after 72 hours. If the WeChat file has been viewed,

Photos cannot open this file because the format is not supported or the file is corrupted Photos cannot open this file because the format is not supported or the file is corrupted Feb 22, 2024 am 09:49 AM

In Windows, the Photos app is a convenient way to view and manage photos and videos. Through this application, users can easily access their multimedia files without installing additional software. However, sometimes users may encounter some problems, such as encountering a "This file cannot be opened because the format is not supported" error message when using the Photos app, or file corruption when trying to open photos or videos. This situation can be confusing and inconvenient for users, requiring some investigation and fixes to resolve the issues. Users see the following error when they try to open photos or videos on the Photos app. Sorry, Photos cannot open this file because the format is not currently supported, or the file

Preparing for removal takes a long time in Windows 11/10 Preparing for removal takes a long time in Windows 11/10 Feb 19, 2024 pm 07:42 PM

In this article, we will introduce how to solve the problem of "Ready to delete" prompt when deleting files or folders in Windows system. This prompt means that the system is performing some background operations, such as checking file permissions, verifying whether the file is occupied by other programs, calculating the size of the item to be deleted, etc. We will provide you with some workarounds to ensure that you can successfully delete your files without waiting too long. Why does Windows take so long to delete files? The time it takes Windows to prepare a file for deletion is affected by a variety of factors, including file size, storage device speed, and background processes. A long or stuck "Preparing to delete" prompt may indicate insufficient system resources, disk errors, or file system issues. exist

Can Tmp format files be deleted? Can Tmp format files be deleted? Feb 24, 2024 pm 04:33 PM

Tmp format files are a temporary file format usually generated by a computer system or program during execution. The purpose of these files is to store temporary data to help the program run properly or improve performance. Once the program execution is completed or the computer is restarted, these tmp files are often no longer necessary. Therefore, for Tmp format files, they are essentially deletable. Moreover, deleting these tmp files can free up hard disk space and ensure the normal operation of the computer. However, before deleting Tmp format files, we need to

How to transfer files from Quark Cloud Disk to Baidu Cloud Disk? How to transfer files from Quark Cloud Disk to Baidu Cloud Disk? Mar 14, 2024 pm 02:07 PM

Quark Netdisk and Baidu Netdisk are currently the most commonly used Netdisk software for storing files. If you want to save the files in Quark Netdisk to Baidu Netdisk, how do you do it? In this issue, the editor has compiled the tutorial steps for transferring files from Quark Network Disk computer to Baidu Network Disk. Let’s take a look at how to operate it. How to save Quark network disk files to Baidu network disk? To transfer files from Quark Network Disk to Baidu Network Disk, you first need to download the required files from Quark Network Disk, then select the target folder in the Baidu Network Disk client and open it. Then, drag and drop the files downloaded from Quark Cloud Disk into the folder opened by the Baidu Cloud Disk client, or use the upload function to add the files to Baidu Cloud Disk. Make sure to check whether the file was successfully transferred in Baidu Cloud Disk after the upload is completed. That's it

What to do if the 0x80004005 error code appears. The editor will teach you how to solve the 0x80004005 error code. What to do if the 0x80004005 error code appears. The editor will teach you how to solve the 0x80004005 error code. Mar 21, 2024 pm 09:17 PM

When deleting or decompressing a folder on your computer, sometimes a prompt dialog box &quot;Error 0x80004005: Unspecified Error&quot; will pop up. How should you solve this situation? There are actually many reasons why the error code 0x80004005 is prompted, but most of them are caused by viruses. We can re-register the dll to solve the problem. Below, the editor will explain to you the experience of handling the 0x80004005 error code. Some users are prompted with error code 0X80004005 when using their computers. The 0x80004005 error is mainly caused by the computer not correctly registering certain dynamic link library files, or by a firewall that does not allow HTTPS connections between the computer and the Internet. So how about

What is hiberfil.sys file? Can hiberfil.sys be deleted? What is hiberfil.sys file? Can hiberfil.sys be deleted? Mar 15, 2024 am 09:49 AM

Recently, many netizens have asked the editor, what is the file hiberfil.sys? Can hiberfil.sys take up a lot of C drive space and be deleted? The editor can tell you that the hiberfil.sys file can be deleted. Let’s take a look at the details below. hiberfil.sys is a hidden file in the Windows system and also a system hibernation file. It is usually stored in the root directory of the C drive, and its size is equivalent to the size of the system's installed memory. This file is used when the computer is hibernated and contains the memory data of the current system so that it can be quickly restored to the previous state during recovery. Since its size is equal to the memory capacity, it may take up a larger amount of hard drive space. hiber

How to install GHO files How to install GHO files Feb 19, 2024 pm 10:06 PM

The gho file is a GhostImage image file, which is usually used to back up the entire hard disk or partition data into a file. In some specific cases, we need to reinstall this gho file back to the hard drive to restore the hard drive or partition to its previous state. The following will introduce how to install the gho file. First, before installation, we need to prepare the following tools and materials: Entity gho file: Make sure you have a complete gho file, which usually has a .gho suffix and contains a backup

See all articles