 |
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

January 18th, 2007, 04:19 PM
|
|
Friend of Wrox
|
|
Join Date: May 2005
Posts: 189
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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!
|
|

January 18th, 2007, 07:45 PM
|
|
Friend of Wrox
|
|
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
|
|
;;;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
|
|

January 19th, 2007, 03:49 AM
|
|
Friend of Wrox
|
|
Join Date: May 2005
Posts: 189
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
...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 :)
|
|

January 21st, 2007, 06:52 PM
|
|
Friend of Wrox
|
|
Join Date: May 2005
Posts: 189
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
... the input type=file-problem is now solved!
But one q is left; can I customize the "Browse-to-file"-button?
Mvh
grstad :)
|
|

January 21st, 2007, 07:01 PM
|
|
Friend of Wrox
|
|
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
|
|
;;;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
|
|

January 22nd, 2007, 10:00 AM
|
|
Friend of Wrox
|
|
Join Date: May 2005
Posts: 189
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
...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 
|
|

January 22nd, 2007, 10:13 AM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
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^^
================================================== =========
|
|

January 22nd, 2007, 10:31 AM
|
|
Friend of Wrox
|
|
Join Date: May 2005
Posts: 189
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
...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: [email protected]
' 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 :)
|
|

January 22nd, 2007, 10:46 AM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
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^^
================================================== =========
|
|

January 22nd, 2007, 03:55 PM
|
|
Friend of Wrox
|
|
Join Date: May 2005
Posts: 189
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
...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 
|
|
 |