473,386 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

file operations using javascript

hi

i was trying to delete a file in a javascript function but couldn't do it.


Expand|Select|Wrap|Line Numbers
  1. myActiveXObject = new ActiveXObject("Scripting.FileSystemObject");
  2.   file = myActiveXObject.GetFile("c:\\file.txt");
  3.   file.Delete();
this code will work in IE
but not in firefox
is there any other way using javascript to delete a file

thanks in advance
Dec 21 '07 #1
6 8057
gits
5,390 Expert Mod 4TB
it IS only possible with IE and activeX and loose security setting ... imagine a webpage that is able to delete files from your filesystem ... or even could read them ;) ... nobody wants that ...

is this for an intranet application?

kind regards
Dec 21 '07 #2
apologies

i forgot to mention
i will be deleting the files which the user has uploaded on the server
and not those that are on the clients computer.

and after i read your post
i realised i need to change the path in the getfile function

file = myActiveXObject.GetFile("localhost/upload/images.jpg");

but now it is giving an error
file not found

please help

to summarize
just tell me a way
to delete files on the server using javascript
Dec 21 '07 #3
i m still stuck up\please help
Dec 21 '07 #4
gits
5,390 Expert Mod 4TB
hi ...

you cannot delete files on the server directly using javascript ... but you could do an ajax-request that calls a server-side script to do it for you ... so you could produce a list of available files at the server ... create a delete button or something like that ... and when the user performs the delete action (click or whatever) ... send the request and let the serverside do the deletion ... then update the list and show it to the user again :)

kind regards
Dec 21 '07 #5
Markus
6,050 Expert 4TB
Adding to gits post and the 'server-side' script he is speaking of.

You'd probably be best using the unlink()

[php]
<?php
$File = $_GET['delete'];
unlink($File) or die ("Couldn't open file for deletion");
?>
[/php]

The unlink() function has to be a script in the same directory as the file being deleted.

Hope this helps and if you need further assistance let it be told :D

- markus.
Dec 21 '07 #6
thanks

i did it using ajax.
i was wondering whether there was any other method.
thanks once again for replying
the matter is solved
Dec 22 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Peter | last post by:
Hello, Two newbie questions: 1) I have a javascript file with a function in it. From this function I want to access a variable in another javascript file -which is not inside a function. I...
2
by: Jerry | last post by:
Hi all! I have a small website and am having a slight difficulty keeping up with the changes needed to keep it current and fresh. I have a lot a archived pages that I'd like to rotate maybe in...
20
by: Nick | last post by:
Right now I'm using document.write("<script language='javascript' src='jsFile" + i + ".js'></script>"); It works -- I have a lot of data in each file and only want the visitor to have to...
11
by: Konrad Den Ende | last post by:
I have a script placed somewhere in the body of my HTML-doc. I noticed that i'll be using the very same script in a large number of document (all of them as the script regards the time of the most...
12
by: A.M. | last post by:
Hi at all, how can I do to insert into a HTML page a file .txt stored in the same directory of the server where is the html file that must display the text file.txt? Thank you very much P.Pietro
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
9
by: Julien Biezemans | last post by:
Hi! Here is the problem: I'd like to restrict local filesystem stream operations to one directory just like a root jail. fopen('/file.bin') would actually open /some/path/file.bin. One goal...
18
by: walterbyrd | last post by:
I am trying to develop an app where: the same file, in the same place, will be uploaded, and then processed. Everything I can find about uploading a file, uses a form that requires the user to...
12
by: Marc | last post by:
Comming from JSP-HTML when I hear 'script' I think of JavaScript or perhaps VBScript. But I think in ASP.NET they mean something else? I am bit confused now. Reading a book I see the following:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.