Jump to content

How to use the unlink function?


Jurik

Recommended Posts

Hi people i'm trying to work-out how to use the unlink() function in PHP, I have a file in a folder called videos can the file is called ICT_Video how do I go about using the unlink function to delete this file when the delete link is pressed?
Link to comment
Share on other sites

Hi

as long as you have permission to delete the file you can just call

[code]<?php
$filename = "/tmp/ictmovie.txt";
unlink($filename);
[/code]

From a web-page the user is something like "apache" or "www-data" so its not "root" therefore you may not have permission to delete the file if its owned by root. If you are running an MS server, im not suer how the persmissions work but you need to check in IIS or Apache (whatever your web-server is).

Cheers,
tdw
Link to comment
Share on other sites

Im using windows and EasyPHP, its going to run off a local server its not going to be on the internet.

Will I need to set permissions then? Alsonin regards to the $filename = "/tmp/ictmovie.txt"; peice of code. I have the ictmovie.mov stored in a MYSQL database and when the user clicks deletes I want it to find the name of the file from the database, go to the fodler and delete it, is this possible with unlink?
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.