Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 18th, 2007, 04:19 PM
Friend of Wrox
 
Join Date: May 2005
Location: , , Norway.
Posts: 189
Thanks: 0
Thanked 0 Times in 0 Posts
Default input type="file"

Hei!

1) When a client uploads a file to a serverside web-app, it is the path to that file which is uploaded. But how can that file (pic) be displayed on screen later when requested? The path is still pointing to the clients disk!

2) Can you fullfill the picture =

Feiltype:
Microsoft VBScript-kompileringsfeil (0x800A0401)
Forventet slutt på setning
upload_picture_validation.asp, line 22, column 57

picture = "<img src=" & Request.form("picture") & "' height="125" '" & "' width="100" '" & ">"
--------------------------------------------------------^

3) Can the path uploaded be trimed to a shorter, valid path?

4) Can the default browse-to-file-button be manipulated in some way? I mean the button that follows the input type=file ?

Mvh
grstad
__________________
Internet has become favorable with that tool...thank you Tim Berners-Lee!
Reply With Quote
  #2 (permalink)  
Old January 18th, 2007, 07:45 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

;;;how can that file (pic) be displayed on screen later when requested?

What I do:
1..Upload the image to a dir within your web site (EG Gallery) and the 'logical file name' (EG myImgname.gif) to a database field
2..When you want to display the image query the database for the image name:
sql = "SELECT imageSrc FROM gallery..."
and display it like so:
<img src="gallery/<%= trim(rs(0)) %>" >

;;;Can the path uploaded be trimed to a shorter, valid path
This question is answered above

;;;Can the default browse-to-file-button be manipulated in some way?
What kind of way, I do not understand your question.

Wind is your friend
Matt
Reply With Quote
  #3 (permalink)  
Old January 19th, 2007, 03:49 AM
Friend of Wrox
 
Join Date: May 2005
Location: , , Norway.
Posts: 189
Thanks: 0
Thanked 0 Times in 0 Posts
Default

...thank you mat41

How does the input type = file function? Does it establish a virtualy path-name on the server, holding the picture info, the pixel-values?

2) I am trying to assign the var picture a text-value;
picture = "<img src=" & Capture("file_path") & "' height="125" '" & "' width="100" '" & ">"

...but the syntax seems wrong...How do I capture the path? Do I need to set up a form and post/get it? Is it not enough to save the filename to the db?

4) Can I give the text input field and button my own look when using input type = file?

Mvh
grstad :)
Reply With Quote
  #4 (permalink)  
Old January 21st, 2007, 06:52 PM
Friend of Wrox
 
Join Date: May 2005
Location: , , Norway.
Posts: 189
Thanks: 0
Thanked 0 Times in 0 Posts
Default

... the input type=file-problem is now solved!

But one q is left; can I customize the "Browse-to-file"-button?

Mvh
grstad :)
Reply With Quote
  #5 (permalink)  
Old January 21st, 2007, 07:01 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

;;;How does the input type = file function?
all that does is open a browsable window for you to pick your file from your local machine.

There are many ways to skin a cat. I have told you the way I do it, you need not store anything but the image name in a text type data base field. FYI the width and height does not need to be stored, nor be present in the image tag.

How do I establish a path (using absolute URL's):
I have a file called global.asp in this file are all my constants, a good practice so you can change one file which takes a global effect on all pages. The DOCBase is one of them, EG:
Const DOCBase = "http://localhost/SiteRootDir/gallery/"

Therefore the path will be:
<img src="<%= DocBase %>gallery/<%= trim(getInfo(4)) %>">

You say:
;;;How do I capture the path?
You dont need to. Since you said 'When a client uploads a file to a serverside web-app' I assume you have uploaded it to the web server, have you? If not you need to, this places the file into the location your DOCBase referrs to. Now you know where the file is, the DOCBase always remains the same therefore you only need to store and extract the filename and append it. For a very nice pure ASP upload script check out:
http://p2p.wrox.com/topic.asp?TOPIC_...ure,ASP,upload

;;;Can I give the text input field and button my own look when using input type = file?
Very good question. I have posted this in the CSS section of this forum. The CSS experts here say no, its safe to say no you cant.

Wind is your friend
Matt
Reply With Quote
  #6 (permalink)  
Old January 22nd, 2007, 10:00 AM
Friend of Wrox
 
Join Date: May 2005
Location: , , Norway.
Posts: 189
Thanks: 0
Thanked 0 Times in 0 Posts
Default

...do you mean global.asa? By following an url posted by you, I have now succeded in uploading images to the server. I do not know if it will "func" in the real www-world, but it does locally; the boundeled IIS version, access and my asp-pages. It stores only the filename and its extension; "pic.gif". That was what I thought of when talking about "trimmed"...leaving out the leftmost part of the path!

Now I am trying to validate the upload form field (input type = "file"). I have tried;

    If instr(the_field,".jpg") Then
        Else
            Response.redirect "my_error_page.asp?Error_msg = Must
            be .jpg!"
    End if

but it does not work. Maybe the included page upload.asp interfere with this. I could try it on a page of its own...a separat validation-page. I have seen an url pointing at some java-script validation, can you repeat that url mat41? A client-side validation maight be better!

I do not want the clients to upload anything else than .jpg, .gif and width="100", height="125".

I do realise I already have got a lot of attention in this fora lately, but...

Mvh
grstad
Reply With Quote
  #7 (permalink)  
Old January 22nd, 2007, 10:13 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

IMHO i would NOT limit your users to width="100", height="125" simply because you can resize the image incode. The reason I even bring this up, how many run of the mill users have an application like Photoshop or PaintShop Pro installed on their PC where they will be able to resize their own images?


In so far as checking for the existance of .jpg, what component are you using to upload files? The reason I ask is because most of the component will deal with the byte data of the image, and a very small part will have anything to do with the actual NAME of the file itself, in the above example, are you SURE 'the_field' refers to the name of the image as opposed to the actual BYTE data?




================================================== =========
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Reply With Quote
  #8 (permalink)  
Old January 22nd, 2007, 10:31 AM
Friend of Wrox
 
Join Date: May 2005
Location: , , Norway.
Posts: 189
Thanks: 0
Thanked 0 Times in 0 Posts
Default

...yes, rezise incode, that must be the way...

The_field;

the_field = Request.form("the_field") 'the input type="file" form which says F:\kbh\kjb\pic.jpg


The component, no I do not know. The code is cut and paste via an url posted by mat41;

'***************************************
' File: Upload.asp
' Author: Jacob "Beezle" Gilley
' Email: avis7@airmail.net
' Date: 12/07/2000
' Comments: The code for the Upload, CByteString,
' CWideString subroutines was originally
' written by Philippe Collignon...or so
' he claims. Also, I am not responsible
' for any ill effects this script may
' cause and provide this script "AS IS".
' Enjoy!
'****************************************


Mvh
grstad :)
Reply With Quote
  #9 (permalink)  
Old January 22nd, 2007, 10:46 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

What value is inStr returning?

================================================== =========
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Reply With Quote
  #10 (permalink)  
Old January 22nd, 2007, 03:55 PM
Friend of Wrox
 
Join Date: May 2005
Location: , , Norway.
Posts: 189
Thanks: 0
Thanked 0 Times in 0 Posts
Default

...probably it ain't no text-string;

Feiltype:
Request-objekt, ASP 0206 (0x80004005)
Kan ikke kalle BinaryRead etter å ha brukt Request.Form-samlingen.
(Can not make any request for BinaryRead using the Request-object, the Form-method)
/df/upload.asp, linje 46;

        biData = Request.BinaryRead(Request.TotalBytes)

Maybe I will have to set up the validation test vis á vis the db-field?

Mvh
grstad
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Input type=file apply a filter?? italiansensation ASP.NET 1.x and 2.0 Application Design 3 May 24th, 2006 04:06 AM
INPUT type=file (Urget Help) surendran PHP How-To 1 April 9th, 2006 12:42 PM
input type file darkhalf Javascript 1 October 29th, 2005 02:17 AM
defining location for input type file bleitner Javascript How-To 1 August 24th, 2004 08:15 AM
<input type="File"> - Specify File Type and Path gp_mk Classic ASP Basics 2 August 2nd, 2004 03:07 AM



All times are GMT -4. The time now is 08:28 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.