LMSouq
server-admin Open

PHP - Move a file into a different folder on the server

OD
odd_duck
1 month ago
3 views
Problem Description
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. (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: 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

AI-Generated Solution

Powered by LMSouq AI · GPT-4.1-mini

✓ Solution Ready
Analyzing problem and generating solution…
Was this solution helpful?
Back to Knowledge Base