Dear friends,
I had host a server and now I have some problem.
I want to click on my web page and delete certain files in my computer. For instance, there is .txt file in my C Drive and I want to delete it, lets assume the file is at "C:\testing.txt ". So, since I host a server, I want to delete this file when I click some buttons at the web page. Is that possible?
Appreciate for any reply. Thank you.
Best Regards.
9 3031 Motoma 3,237
Recognized Expert Specialist
[PHP]<?php
exec("del C:\\somefile.tx t");
?>[/PHP]
Dear Motoma,
I had tried the code, but it did not delete the file I chosen. By the way, after I tried the code, my Kaspersky detect a virus... ...It is coincidence? Or the code got problem? ^^haha. Dont get me wrong, I'm didnt mean that you send me virus, maybe the code will attract something, i guess... ... I believe this is a forum that helping us to solve problem. I had gain many knowledges here.
By the way, thanks for the reply, I will try the code again.
Best Regards.
vssp 268
Contributor
using unlink function to delete the files
Yeah try
[PHP]<?php
unlink("C:/testing.txt");
?>
[/PHP]
Notice the forward slash
Yeah try
[PHP]<?php
unlink("C:/testing.txt");
?>
[/PHP]
Notice the forward slash
Dear friend,
Thank you!!! It works!!!
Erm...then if I want to create a file, how can I do it? I mean I need to delete the file,for instance, "testing.tx t" because there are unwanted data store in there. So, after I delete it, I need to create a same file "testing.tx t" back to the same place, of course, with empty data.
By the way, can anyone tell me how to create a "browse box"? It called a browse box right? haha^^. Something like when I upload photo to friendster, there are a emtpy text box and beside it has a button "browse".
Thanks for the reply.
Best Regards.
Dear friend,
Thank you!!! It works!!!
Erm...then if I want to create a file, how can I do it? I mean I need to delete the file,for instance, "testing.tx t" because there are unwanted data store in there. So, after I delete it, I need to create a same file "testing.tx t" back to the same place, of course, with empty data.
By the way, can anyone tell me how to create a "browse box"? It called a browse box right? haha^^. Something like when I upload photo to friendster, there are a emtpy text box and beside it has a button "browse".
Thanks for the reply.
Best Regards.
Try
[PHP]
<?php
$file = "C:/testing.txt";
if(!file_exists ($file)) {
$fout = fopen($file, "w");
}
?>
[/PHP]
For opening the file
Dear r035198x,
I dont get the idea. What is this mean anyway "$fout = fopen($file, "w"); "?? Well, I just tried it, but the "testing.tx t" file still there, and the data I wrote in "If it works it will be blank later" still remain in the "testing.tx t".
Best Regards
Dear r035198x,
I dont get the idea. What is this mean anyway "$fout = fopen($file, "w"); "?? Well, I just tried it, but the "testing.tx t" file still there, and the data I wrote in "If it works it will be blank later" still remain in the "testing.tx t".
Best Regards
I thought you said you have already deleted the file and now want to create a new one in which case that code will create the new file which will be blank.
Dear r035198x,
Thanks for the reply. I know what happen already, I think I made a big mistake. haha^^.
Hrm, actually, instead of delete and replace a same file, is there any other way such like delete the data ONLY?
Wow, If I only read books to find out, it might take more time. haha^^ PHP really tough.
Best Regards.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: andrea kampa |
last post by:
Hi all,
I'm a Win2000 professional user - sP 4. I can't delete some folders in
e:\inetpub\wwwroot\...\.
I've created them by FrontPage2000 SR1. I enter Windows as Administrator,
then I should be able to
create /delete all objects. On the contrary, each time I attempt to erase
the assigned folder Windows
warns me so:
"Access is denied. The...
|
by: Mark Reed |
last post by:
Hi all,
I have the following code which imports the contents of all files within
a set folder which works excellently. Once it has imported from each file,
it deletes the file. Is there a way that instead of deleting the file, I can
move it to a log somewhere?
Private Sub Command0_Click()
'procedure to import all files in a directory and...
|
by: krock_112 |
last post by:
I'm trying to set up a group of shared folders.
Folder 1
Folder 2
Common Share
I want all users that have access to folder 2 to be able to create new
folders, add documents to the sub folders, pretty much do everything
but delete. I have been unsuccesful so far. I either have to give
everyone complete access which then gives them the...
|
by: Paul |
last post by:
I'm trying to make get my app to delete all the files in a specified folder
and all the files within the folders of the specified folder.
e.g.
Folder 1 contains three files (File1, File2, File3) and two folders
(Subfolder 1, Subfolder 2).
.......I need to delete File1, File2, File3.
Subfolder 1 contains FileA.
.......Need to delete FileA....
|
by: Dan |
last post by:
Hi - I'm about a week into learning VB.NET, and I'm finding I can't delete
any of the VB.NET directory structures that contain my test projects I've
been trying to create. I've never seen this before... Whenever I try, it
says something like "access is denied" and "make sure the disk is not
write-protected and file is not currently in use". ...
| |
by: nospam |
last post by:
I am writing this app in .net 2003 since all machines don't have 2.0
framework. I am trying to delete old profiles, but I am getting access
denied or file in use errors. A lot of these files I am able to delete
in Windows Explorer.
The app is getting launched using the System account, so there is
plenty of rights to delete the files.
I...
|
by: - HAL9000 |
last post by:
When un-installing an application...
Is it normal practice to write a special program that erases all the
files and folders for all the users of an application that reads and
writes to SpecialFolder.ApplicationData (C:\Documents and
Settings\Username\Application Data) ?
Or, is there some way to get the ms installer to do this for you?
...
|
by: Sam |
last post by:
This is probably the wrong group to post this in, but I'm not sure
where it should go. If you have suggestions as to another group to
post it let me know.
In our Nant build file for our application. I want to first delete 2
folders if they exist. These folders then later get created. If the
folders exist, I do not get errors, but if...
|
by: Matt |
last post by:
I have several folders on a server that contains files that go back 3-4 years. It was mentioned that keeping files that long is no longer needed. So my question is, is there a way to create a windows service in C# that can delete files in the folders that are older then 12 months?
The server is structured something like this:
DataLogs...
|
by: wolfsbane |
last post by:
Alright, here it is I am trying to write a win32 app in VB 2005 to clean up user's profiles. everything works correctly except for the Delete("directory", True) statement. I get a System.IO.DirectoryNotFoundException: Could not find a part of the path. Then it gives me a random file name from the UserProfile\Local Settings\Temporary Internet...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |