Board index   FAQ   Search  
Register  Login
Board index PHP PHP Scripts

Server-side file managing

Links for php scripts

Moderators: macek, egami, gesf

Server-side file managing

Postby drimades » 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!

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

Postby bezmond » Wed Feb 18, 2004 11:28 am

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

Postby swirlee » Wed Feb 18, 2004 11:59 am

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

Postby bezmond » 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
bezmond
Moderator
Moderator
 
Posts: 312
Joined: Sat Apr 05, 2003 4:33 am
Location: Mansfield, UK

Postby gesf » 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!
User avatar
gesf
Moderator
Moderator
 
Posts: 1717
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden

Re: Server-side file managing

Postby WiZARD » 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
User avatar
WiZARD
Moderator
Moderator
 
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol


Return to PHP Scripts

Who is online

Users browsing this forum: No registered users and 0 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.