Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Prompt for Attachment from ASP/WEB page (clarification)

Status
Not open for further replies.

DougP

MIS
Dec 13, 1999
5,985
0
36
US
I got this ASP code a few days ago. but it is for usage on the Internet server itself. We don't host our own WEB site.

Is there a way to modify this so it will save to our WEB site folder and not the WEB hosts C:\drive ????
Her is the link and the code below
----------------------
<%
Dim MyUploader
Set MyUploader = New FileUploader
%>

<%
MyUploader.Upload()
%>

<%
MyUploader()
%>


<%
Dim File
For Each File In MyUploader.Files.Items
Response.Write &quot;File Name:&quot; & File.FileName
Response.Write &quot;File Size:&quot; & File.FileSize
Response.Write &quot;File Type:&quot; & File.ContentType
Next
%>

<%
Response.Write &quot;File Name:&quot; & MyUploader.Files(&quot;file1&quot;).FileName
Response.Write &quot;File Size:&quot; & MyUploader.Files(&quot;file1&quot;).FileSize
Response.Write &quot;File Type:&quot; & MyUploader.Files(&quot;file1&quot;).ContentType
%>

<%
Dim File
For Each File In MyUploader.Files.Items
File.SaveToDisk &quot;C:\UploadedFiles&quot;
Next
%>

<%
Dim RS
Dim File

Set RS = Server.CreateObject(&quot;ADODB.Recordset&quot;)
RS.Open &quot;MyUploadTable&quot;, &quot;CONNECT STRING OR ADO.Connection&quot;, 2, 2

For Each File In MyUploader.Files.Items
RS.AddNew

RS(&quot;filename&quot;) = File.FileName
RS(&quot;filesize&quot;) = File.FileSize
RS(&quot;contenttype&quot;) = File.ContentType

File.SaveToDatabase RS(&quot;filedata&quot;)

RS.Update
Next

RS.Close
%>
DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
Try File.SaveToDisk Server.MapPath(&quot;/UploadedFilesDirectoryInWebFolder&quot;)

See if the permissions are right...
gettin' jiggy wid' it --
smbure
 
How do I call it ????

I would like them to click a button or link and pop up a dialog box whihc would let them choose a file from their computer.
then click OK or submit
and then have it saved to a folder on our WEB site.

DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
I think what smbure what trying to get at was that the component is going to have to have a &quot;c:\path&quot; type of argument in order to work.

And that's what server.mappath is for -- it will return to you the absolute path on your web server -- and will usually look something like:

d:\users\mikep\etc...

so that you give it a virtual path (i.e. what you already know) and it will return to you an absolute, which is what you need --

Play around with it -- response.write the results of one and see what it looks like. It should make sense after you do that.

:)
Paul Prewett
penny.gif
penny.gif
 
Ok I get it,
thanks both of you
I'll let you know how it works
DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
Ok I get this error
--------------------------------------------
Server object error 'ASP 0177 : 800a0046'

Server.CreateObject Failed

/upload/upload.asp, line 133

The operation completed successfully.
--------------------------------------------

I also e-mailed Persits and Peter himslef responded and said it only works on the Server and you cannot save to a URL path.

DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
Is there a way to Call the &quot;COMDLG32.OCX&quot; from my .ASP page
and then use the
Server.MapPath(&quot;/UploadedFilesDirectoryInWebFolder&quot;)

I use this all the time in Access and VB
Like so:

CommonDialog1.DialogTitle = &quot;Upload file&quot;
CommonDialog1.DefaultExt = &quot;.txt&quot;
CommonDialog1.Filter = &quot;Text Files(*.txt)|*.txt|All Files (*.*)|*.*&quot;
CommonDialog1.InitDir = &quot;C:\&quot;
CommonDialog1.Action = 1
grdDataGrid.Columns(2).Value = CommonDialog1.filename
---------------

And if so, do I Declare it?
Declare COMDLG32.OCX .........



DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
I can't believe I didn't see this before:

Set MyUploader = New FileUploader

should be:
set MyUploader = server.createObject(&quot;PERSITS.FileUploader&quot;)

That's where your createObject was failing --

Now, this IS running on a server, right? So that part of Peter's response should be a moot point -- and you aren't trying to save it to a URL if you use server.mappath -- it will be saving to an absolute path...

You should be good to go.
penny.gif
penny.gif
 
link9
I stil get the same Error

OK her it is.
We have a Host, &quot;Internet Junction&quot; hosting our site
So the Server where our WEB site is, is not in our building its in another city. I have no control over it.

We are using Front page 2000 and they have the latest Front page 2000 Sever extensions (went through that mess on another issue)

also I know our site is on an NT Server and not Apache (went through that mess on another issue too)
DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
So how much do you know about calling the COMDLG32.OCX
control from a WEB page
right now nothing happens at all when I click the button

here is that code:
------------------------
<body>
<script Language=&quot;VBScript&quot;>

Sub Browse_OnClick

CommonDialog1.Action = 1

End Sub
</script>

<form method=&quot;POST&quot; action=&quot;--WEBBOT-SELF--&quot;>
<!--webbot bot=&quot;SaveResults&quot; startspan
U-File=&quot; S-Format=&quot;TEXT/CSV&quot; S-Label-Fields=&quot;TRUE&quot; --><input TYPE=&quot;hidden&quot; NAME=&quot;VTI-GROUP&quot; VALUE=&quot;0&quot;><!--webbot
bot=&quot;SaveResults&quot; endspan --><p><input type=&quot;text&quot; name=&quot;T1&quot; size=&quot;34&quot;>
<input type=&quot;button&quot; value=&quot;Browse (your computer)&quot; name=&quot;Browse&quot;>
<object classid=&quot;clsid:F9043C85-F6F2-101A-A3C9-08002B2F49FB&quot; id=&quot;CommonDialog1&quot; width=&quot;32&quot; height=&quot;32&quot;>
<param name=&quot;_ExtentX&quot; value=&quot;847&quot;>
<param name=&quot;_ExtentY&quot; value=&quot;847&quot;>
<param name=&quot;_Version&quot; value=&quot;393216&quot;>
<param name=&quot;CancelError&quot; value=&quot;0&quot;>
<param name=&quot;Color&quot; value=&quot;0&quot;>
<param name=&quot;Copies&quot; value=&quot;1&quot;>
<param name=&quot;DefaultExt&quot; value=&quot;*.jpg&quot;>
<param name=&quot;DialogTitle&quot; value=&quot;Upload File&quot;>
<param name=&quot;FileName&quot; value>
<param name=&quot;Filter&quot; value>
<param name=&quot;FilterIndex&quot; value=&quot;0&quot;>
<param name=&quot;Flags&quot; value=&quot;0&quot;>
<param name=&quot;FontBold&quot; value=&quot;0&quot;>
<param name=&quot;FontItalic&quot; value=&quot;0&quot;>
<param name=&quot;FontName&quot; value>
<param name=&quot;FontSize&quot; value=&quot;8&quot;>
<param name=&quot;FontStrikeThru&quot; value=&quot;0&quot;>
<param name=&quot;FontUnderLine&quot; value=&quot;0&quot;>
<param name=&quot;FromPage&quot; value=&quot;0&quot;>
<param name=&quot;HelpCommand&quot; value=&quot;0&quot;>
<param name=&quot;HelpContext&quot; value=&quot;0&quot;>
<param name=&quot;HelpFile&quot; value>
<param name=&quot;HelpKey&quot; value>
<param name=&quot;InitDir&quot; value=&quot;c:\&quot;>
<param name=&quot;Max&quot; value=&quot;0&quot;>
<param name=&quot;Min&quot; value=&quot;0&quot;>
<param name=&quot;MaxFileSize&quot; value=&quot;260&quot;>
<param name=&quot;PrinterDefault&quot; value=&quot;1&quot;>
<param name=&quot;ToPage&quot; value=&quot;0&quot;>
<param name=&quot;Orientation&quot; value=&quot;1&quot;>
</object>
</p>
<p><input type=&quot;submit&quot; value=&quot;Submit (file to Universal)&quot; name=&quot;Submit&quot;>
<input type=&quot;reset&quot; value=&quot;Reset&quot; name=&quot;B2&quot;></p>
</form>
<p>&nbsp;</p>

</body>

I added the common dialog from Front page and it is sitting on the form.
Front page added all of the <Param name ...> items when I sved the page

but when I click the &quot;Browse&quot; button nothing happens at all
No Error, nothing

I put the COMDLG32.OCX in the same folder on the WEB site as this .ASP page it in.

DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
Crap -- When will I shake the cobwebs out?

That .dll is going to have to be registered on the server in order for you to be able to use it (but you already knew that, and I kept arguing with you) -- sorry about that.

So the question is... &quot;Will my provider register a custom library on my server for me?&quot;

Some will, and some won't. If they will (they should know of PERSITS, and not give you much trouble about it if they have a policy of registering them), then you just sent them the .dll and get them to register it.

If they won't, then you're going to have to go a completely different route -- and I know nothing about that common dialog that you mentioned, so I'm going to have to reserve comment on that one --

I wonder about the fileSystemObject -- is there some way to use that to get what you need? Using the regular old HTML <input type=file> ??

I don't do this type of thing, so I wish I could offer more advice. Maybe someone else can comment on the use of the FSO and <input type=file> --

I hope your ISP will register the .dll, though.

good luck
paul
penny.gif
penny.gif
 
No I didn't know that about registering.
I tend to take alot of things for granted.
And when I get something to work I copy and paste the final code in my goody bag for later use.
I really program 90% of everything from those code snippets in my goody bag (a folder called &quot;dougcode&quot; on my hard drive)

Ok I'll ask them about registering


DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
Ha
link9 I did it, Without having the ISP register it.
Open your goody bag and stuff this in it....

But it maybe already registerd casues it is a very common .OCX anyway and it's probably on their NT server already. I don't know fer sure dude

I added thses lines
<body>
<script Language=&quot;VBScript&quot;>

Sub Browse_OnClick
[red]Set theForm = document.FrontPage_Form2[/color]
[red]theForm.[/color]CommonDialog1.Action = 1

End Sub
</script>

And gave the form a name too
[red]<form method=&quot;GET&quot; action=&quot;finalorder.asp&quot; name=&quot;FrontPage_Form2&quot;>[/color]

So when I click the button it pops up the common dialog box

I know from other things ZI've done you have to be explict about telling .ASP waht to do IE &quot;theform....&quot;

No I did not get it to save a file yet but I'll figure that out next



DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
Ok it only works on my computer

Soo I have to find out why it does not work on ther others
I guess you were right about the registering in on the server.

here is the weird thing.
Each PC that I check it on has the COMDLG32.OCX
on it
And I even used the regserv ... command to register the file on a PC and it still did not work.

RegSvr32.Exe c:\Winnt\system32\COMDLG32.OCX

It only works on a PC if Visual Basic is installed on it.
DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top