PHP - 将文件移动到服务器上的不同文件夹中 - PHP - Move a file into a different folder on the server

10/17 08:17
阅读数 0

问题:

I need to allow users on my website to delete their images off the server after they have uploaded them if they no longer want them.我需要允许我网站上的用户在上传图像后从服务器上删除他们不再需要的图像。 I was previously using the unlink function in PHP but have since been told that this can be quite risky and a security issue.我以前在 PHP 中使用过unlink函数,但后来被告知这可能非常危险且存在安全问题。 (Previous code below:) (以前的代码如下:)

if(unlink($path.'image1.jpg')){ 
     // deleted
}

Instead i now want to simply move the file into a different folder.相反,我现在只想将文件移动到不同的文件夹中。 This must be able to be done a long time after they have first uploaded the file so any time they log into their account.这必须能够在他们第一次上传文件后的很长时间内完成,以便他们登录他们的帐户时。 If i have the main folder which stores the users image(s):如果我有存储用户图像的主文件夹:

user/

and then within that a folder called del which is the destination to put their unwanted images:然后在那个名为 del 的文件夹中,该文件夹是放置不需要的图像的目的地:

user/del/

Is there a command to move a file into a different folder?是否有将文件移动到不同文件夹的命令? So that say:所以说:

user/image1.jpg

moves to/becomes移动到/变成

user/del/image1.jpg

解决方案:

参考一: https://en.stackoom.com/question/1IJ2Y
参考二: https://stackoom.com/question/1IJ2Y
展开阅读全文
php
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部