473,804 Members | 3,481 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

file operations using javascript

18 New Member
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 8090
gits
5,390 Recognized Expert Moderator Expert
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
mitchell
18 New Member
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("local host/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
mitchell
18 New Member
i m still stuck up\please help
Dec 21 '07 #4
gits
5,390 Recognized Expert Moderator Expert
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 Recognized Expert Expert
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
mitchell
18 New Member
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
12412
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 have tried many combinations to do this, but has yet to try the right one. How is it done? 2) What kinds of file operations can be done in Javascript (save,
2
3731
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 case I haven't prepared a new days worth of content. What I'm asking... ....is it possible to access html files on my files on my hosted site's server for the simple process of copying and pasting the code into another newly created file prior to...
20
1858
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 download the necessary file. Is there a better way to do this? Just curious because the page doesn't validate in HTML validators.
11
1747
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 recent edition of the given file). I could place the script in every single document BUT: 1. I'm far too lazy to go through 100 documents doing one and the same thing. That's for monkeys, not lazy humans. 2. Even if i wasn't so lazy, i'd have...
12
2599
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
3945
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. It is almost like it is trying to implement it's own COM interfaces... below is the header, and a link to the dll+code: Zip file with header, example, and DLL:...
9
3460
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 of this behavior is to prevent Xinclude instructions to point to "out of application directory" files when processed by the XSLT processor, among other things.
18
2340
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 either manually enter the path and file name, or to browse for the file. I do not want that. Ideally, I want the user to click on a link, and the server side php app does the rest. Again, the file always has the same name, and is in the same place....
12
1749
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: A simple Web page may look like the following. <!-page directives--> <%@ Page Language="VB" %>
0
9710
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9589
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10340
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10085
tracyyun
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7626
isladogs
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6858
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5527
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5663
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4304
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.