May 12, 200917 yr <?php $dir = 'images/'; $filename = 'image1.jpg'; unset($dir.$filename); ?> This would delete a picture located in images/image1.jpg
May 12, 200917 yr Author <?php $dir = 'images/'; $filename = 'image1.jpg'; unset($dir.$filename); ?> This would delete a picture located in images/image1.jpg Where would I put this? Because I have an upload form, and the user uploads the pics to an folder on the server then they go into a gallery to display the pictures so where would I put that peace of code ?
May 12, 200917 yr When you upload a file via PHP, it is saved in a temp folder. You have the ability to process this file, and to copy it to a desired location if needed (which I guess would be your gallery directory e.g. images/gallery). Where the code would go would depend on when you actually wanted to delete a picture. During the part of your code where you want to delete a picture, you can insert the code and change the filename/directory as needed. If you're using a functions file then you could implement the above code as a simple function which you could call at any point in your script where you need to delete a file.
Create an account or sign in to comment