使用javascript从文件夹中删除文件 [英] Delete file from folder using javascript

查看:88
本文介绍了使用javascript从文件夹中删除文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

在服务器路径上保存了一个图像文件。我想用javascript从该文件夹中删除该图像





谢谢

Hi all,
Saved one image file on server path.I want to delete that image from that folder using javascript


Thanks

推荐答案

用简单的单词回答:你不能



理由:

Javasctipt是客户端脚本语言。这将仅在客户端浏览器上运行。您无法使用javascript与服务器进行交互。要从服务器(服务器目录)中删除文件,您需要使用C#函数,例如 File.Delete(MyFilePath) [ ^ ]。如果您在删除文件时不想要回发,则可以使用 UpdatePanel [ ^ ]部分更新页面。





--Amit
Answer in Simple words : "You Can''t".

Reasons:
Javasctipt is client side scripting language. This will run on client browser only. You cannot interact with server using javascript. To delete the files from server(server directory), you need to use C# function, such as File.Delete("MyFilePath")[^]. If you don''t want a postback while deleting the files then you can use UpdatePanel[^] to update the page partially.


--Amit






Javascript 函数只能访问客户端计算机的资源。所以你不能从javascript中删除服务器中的文件。我建议接受服务器事件并从后面的代码中删除。
Hi,

Javascript functions have got access only to client machine''s resources. so you cannot delete the file in server from javascript. i suggest to take a server event and delete from code behind.


javascript是客户端脚本语言使用PHP函数
javascript is client side scripting language use PHP function instead


这篇关于使用javascript从文件夹中删除文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆