Server-side file managing

Links for php scripts

Moderators: egami, macek, gesf

Post Reply
drimades
New php-forum User
New php-forum User
Posts: 39
Joined: Wed Oct 29, 2003 2:11 pm

Wed Feb 18, 2004 8:50 am

---------------------------------

Hello!

1 - How can I delete a file (say "C:\dog.jpg") using a php script?

2 - How can I limit the upper size of uploaded files to 200 Kb

Thank you!

---------------------------------

User avatar
bezmond
Moderator
Moderator
Posts: 312
Joined: Sat Apr 05, 2003 4:33 am
Location: Mansfield, UK
Contact:

Wed Feb 18, 2004 11:28 am


User avatar
swirlee
Moderator
Moderator
Posts: 2257
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back
Contact:

Wed Feb 18, 2004 11:59 am

Image

User avatar
bezmond
Moderator
Moderator
Posts: 312
Joined: Sat Apr 05, 2003 4:33 am
Location: Mansfield, UK
Contact:

Wed Feb 18, 2004 1:12 pm

I know, but it gave him a link to start looking... don't want to give him ALL the answers ;)

User avatar
gesf
Moderator
Moderator
Posts: 1716
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden
Contact:

Thu Feb 19, 2004 5:38 am

You can do something like this:

Code: Select all

function delete_file($file){
    $delete = @unlink($file);
     if (@file_exists($file)){
   $filesys = eregi_replace("/","\\",$file);   
   $delete = @system("del $filesys");
    if (@file_exists($file))
    {
    $delete = @chmod($file, 0755);
    $delete = @unlink($file);
    $delete = @system("del $filesys");
    }
     }
}


Don´t forget to change the directory´s permissions where the file is into!
Sincerely,
Gonçalo "gesf" Fontoura

gesf.org | sessionstart.com | urlms.com

User avatar
WiZARD
Moderator
Moderator
Posts: 1240
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol
Contact:

Thu Feb 26, 2004 3:11 am

to bezmond and swirlee too....
i'm recommend firstly read about permitions and deleting files in different OS...... like in Windows and x/nix
"Sex,Drugs and Rock&Roll " replaced at "Sucks,Bugs and Plug&Play";
Image

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 0 guests