FSO 复制保存文件。 VBScript/ASP页面使用子程序

发布于 2024-12-25 19:18:53 字数 1161 浏览 3 评论 0原文

我正在尝试使用 FSO = Server.CreateObject("Scripting.FileSystemObject") 利用名为“csImageFile”的 ASP 实用程序复制/保存文件

目前,我拥有的 FSO 代码位于单独的 .asp 页面上。当用户选择一个选项时(使用 value="xxx.asp..." 调用代码页),从页面调用此函数。这很好用。

问题在于FSO代码页response.redirects到调用页面并且刷新丢失数据。

我希望选择/选项的“onlclick”通过将代码放置在原始调用页面的子路由中来调用 FSO 代码(从而避免刷新)。我已经通过各种方式尝试过,但没有成功。我目前调用一个 js 函数,该函数本身然后调用一个 VBscript 子例程。这可能不正确,但我已经尝试了很多排列,我现在有点迷失了。

页面上,

<option onclick="calljsSub()"...

在脚本

<script language="JavaScript">
    function calljsSub(){
    //alert("js called");
    VBFunc();
    }
</script>

<script language="VBScript">
    Sub VBFunc()
        SET FSO = Server.CreateObject("Scripting.FileSystemObject")
        If FSO.FileExists ( "path to file") Then
                Set Image = Server.CreateObject("csImageFile.Manage")
                Image.ReadFile "path to file"
                Image.WriteFile Server.MapPath("path to new file")
        end if
        Set FSO = Nothing
    End Sub

VBScript 函数似乎没有执行任何操作。也许还有另一种无需刷新即可运行代码的方法?欢迎任何建议。

我将非常感谢任何建议,因为我从圣诞节前就一直在努力解决这个问题。

马克谢谢 标记

I'm trying to use FSO = Server.CreateObject("Scripting.FileSystemObject") to copy/save files utilising a ASP utility called 'csImageFile'

At present the FSO code I have is on a separate .asp page. This is called from a page when the user selects an option (using value="xxx.asp..." to call code page). This works fine.

The problems is that the FSO code page response.redirects to the calling page and the refresh loses data.

I'd like the 'onlclick' of the select/option to call the FSO code by placing the code in a subrouting on the original calling page (hence avoiding the refresh). I've tried this by various ways without success. I presently call a js function which itself then calls a VBscript subroutine. This is may not be correct but I've tried so many permutations I'm a bit lost now.

on page

<option onclick="calljsSub()"...

the scripts

<script language="JavaScript">
    function calljsSub(){
    //alert("js called");
    VBFunc();
    }
</script>

<script language="VBScript">
    Sub VBFunc()
        SET FSO = Server.CreateObject("Scripting.FileSystemObject")
        If FSO.FileExists ( "path to file") Then
                Set Image = Server.CreateObject("csImageFile.Manage")
                Image.ReadFile "path to file"
                Image.WriteFile Server.MapPath("path to new file")
        end if
        Set FSO = Nothing
    End Sub

The VBScript function appears to do nothing. Perhaps there is another way of runnning the code without refreshing?? Any advice is welcome.

I'd be very grateful for any advice as I've been trying to solve this since before Christmas.

Mark thanks
Mark

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

情丝乱 2025-01-01 19:18:53

这里的问题是你混淆了客户端上发生的事情和服务器上发生的事情:

click event = client
javascript code = client
VB Script = server

你不能从客户端调用服务器上的函数 - 它们是不同的机器。你需要调用一个URL,即一个ASP页面。该 ASP 页面需要查看正在发出的请求,获取发送的任何请求参数,并根据这些参数决定运行哪些代码 - 在本例中是您的 VBFunc()。

这是网页工作原理的最基本功能:

页面->页面。请求->服务器->响应(新页面)

是的,您可以使用 AJAX 技术运行代码而不刷新,但首先尝试让基本工作正常。

The issue here is that you are mixing up what happens on the client and what happens on the server:

click event = client
javascript code = client
VB Script = server

You cannot call a function on the server from the client - they're different machines. You need to call a URL, i.e. an ASP page. This ASP page needs to look at the request being made, grab whatever request parameters are sent and decide which code to run based on those parameters - in this case your VBFunc().

This is the most basic functionality of how web pages work:

page -> request -> server -> response (new page)

Yes, you can run the code without refreshing, using AJAX techniques, but try to get the basic working properly first.

少钕鈤記 2025-01-01 19:18:53

感谢任何试图提供帮助的人。我通过主页上隐藏的 iframe 调用 asp 页面来解决这个问题。干杯。

Thanks for anyone trying to help. I've sort this out by calling the asp page through a hidden iframe on the main page. Cheers.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文