Google Answers Logo
View Question
 
Q: pass contents from a file upload upload field to a text field on parent page ( Answered 5 out of 5 stars,   0 Comments )
Question  
Subject: pass contents from a file upload upload field to a text field on parent page
Category: Computers > Programming
Asked by: binarian-ga
List Price: $30.00
Posted: 28 Sep 2003 14:12 PDT
Expires: 28 Oct 2003 13:12 PST
Question ID: 261009
i have a shop that needs to upload images. i have all the code ready
for upload and image resizing. however, i need to do it like this. on
the product submit page.. a link that says upload image with
TEXTFIELD1 beside it. you click the upload link and it opens
upload.asp in a new browser window. This file has a FILEFIELD so the
user can browse for a picture. my code will upload images and resize
them in upload.asp. NOW..i need to know..what do i need to add to my
code so that when the image upload and resize is complete, the user
can click a
CLOSE link and the FILEFIELD (which will aready contain the image file
name in the field) will then pass the name of the file to the original
product insert page and put this image file name into TEXTFIELD 1....
that products page will then be able to insert all product information
into the database since the files will already be on the server.

THANKS!

here is the code for upload.asp

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="../Connections/ncshoes.asp" -->
<!--#include file="../ScriptLibrary/incResizeAddOn.asp" -->
<!--#include file="../ScriptLibrary/incPureUpload.asp" -->

<%
'*** Pure ASP File Upload 2.1.3
Dim GP_uploadAction,UploadQueryString
PureUploadSetup
If (CStr(Request.QueryString("GP_upload")) <> "") Then
  Dim pau_thePath,pau_Extensions,pau_Form,pau_Redirect,pau_storeType,pau_sizeLimit,pau_nameConflict,pau_requireUpload,pau_minWidth,pau_minHeight,pau_maxWidth,pau_maxHeight,pau_saveWidth,pau_saveHeight,pau_timeout,pau_progressBar,pau_progressWidth,pau_progressHeight
  pau_thePath = """images"""
  pau_Extensions = "GIF,JPG,JPEG,BMP,PNG"
  pau_Form = "form1"
  pau_Redirect = ""
  pau_storeType = "file"
  pau_sizeLimit = ""
  pau_nameConflict = "uniq"
  pau_requireUpload = "true"
  pau_minWidth = ""
  pau_minHeight = "" 
  pau_maxWidth = ""
  pau_maxHeight = ""
  pau_saveWidth = ""
  pau_saveHeight = ""
  pau_timeout = "600"
  pau_progressBar = "blueFlashProgress.htm"
  pau_progressWidth = "300"
  pau_progressHeight = "100"
  
  Dim RequestBin, UploadRequest
  CheckPureUploadVersion 2.13
  ProcessUpload pau_thePath,pau_Extensions,pau_Redirect,pau_storeType,pau_sizeLimit,pau_nameConflict,pau_requireUpload,pau_minWidth,pau_minHeight,pau_maxWidth,pau_maxHeight,pau_saveWidth,pau_saveHeight,pau_timeout
end if
%>
<%
' *** Smart Image Processor 1.1.1
If (CStr(Request.QueryString("GP_upload")) <> "") Then
  Dim RUF_Component, RUF_DotNetResize, RUF_ResizeImages,
RUF_AspectImages, RUF_maxWidth, RUF_maxHeight, RUF_Quality,
RUF_MakeThumb, RUF_AspectThumb, RUF_Suffix, RUF_maxWidthThumb,
RUF_maxHeightThumb, RUF_QualityThumb, RUF_RedirectURL
  RUF_Component = "AUTO"
  RUF_DotNetResize = "../ScriptLibrary/ResizeImage.aspx"
  RUF_ResizeImages = true
  RUF_AspectImages = true
  RUF_maxWidth = "600"
  RUF_maxHeight = ""  
  RUF_Quality = "80"
  RUF_MakeThumb = true
  RUF_AspectThumb = true
  RUF_Suffix = "_small"
  RUF_maxWidthThumb = "100"
  RUF_maxHeightThumb = ""
  RUF_QualityThumb = "70"
  RUF_RedirectURL = ""
  if RUF_ResizeImages then
    ResizeUploadedFiles RUF_Component, RUF_DotNetResize, pau_thePath,
"", RUF_maxWidth, RUF_maxHeight, RUF_Quality, true, pau_saveWidth,
pau_saveHeight, RUF_AspectImages, pau_nameConflict
  end if
  if RUF_MakeThumb then
    ResizeUploadedFiles RUF_Component, RUF_DotNetResize, pau_thePath,
RUF_Suffix, RUF_maxWidthThumb, RUF_maxHeightThumb, RUF_QualityThumb,
false, pau_saveWidth, pau_saveHeight, RUF_AspectThumb,
pau_nameConflict
  end if
  if RUF_RedirectURL <> "" then
    Response.Redirect RUF_RedirectURL
  end if
end if
%>
<%
Dim rsUpload
Dim rsUpload_numRows

Set rsUpload = Server.CreateObject("ADODB.Recordset")
rsUpload.ActiveConnection = MM_ncshoes_STRING
rsUpload.Source = "SELECT * FROM products"
rsUpload.CursorType = 0
rsUpload.CursorLocation = 2
rsUpload.LockType = 1
rsUpload.Open()

rsUpload_numRows = 0
%>

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<script language="javascript"
src="../ScriptLibrary/incPureUpload.js"></script>
</head>

<body>
<br>
<font size="4" face="Verdana, Arial, Helvetica,
sans-serif"><strong>UPLOAD FILE
:</strong></font> <br>
Click browse and select and image from your computer.<br>
Then hit the Upload Image button and a thumnail and resized image will
be created.

 
<form action="<%=GP_uploadAction%>" method="post"
enctype="multipart/form-data" name="form1"
onSubmit="checkFileUpload(this,'GIF,JPG,JPEG,BMP,PNG',true,'','','','','','','');showProgressWindow('blueFlashProgress.htm',300,100);return
document.MM_returnValue">
  <input name="file" type="file"
onChange="checkOneFileUpload(this,'GIF,JPG,JPEG,BMP,PNG',true,'','','','','','','')">
  <br>
</form>
<input type="submit" name="Submit" value="Upload Image">
</body>
</html>
<%
rsUpload.Close()
Set rsUpload = Nothing
%>

Request for Question Clarification by joseleon-ga on 29 Sep 2003 23:37 PDT
Hello, binarian:
  To do this you need to write some JavaScript code that:

-Opens the upload popup window
-Passes the contents of the filefield to the TextField of the opener
window

I can provide the HTML+JS code that do this, after that, it's your
task to integrate it into your ASP code. It's enough for you?

Regards.

Clarification of Question by binarian-ga on 30 Sep 2003 09:23 PDT
hey whatever works. if u have a method u think looks compatible then im all for it!

Request for Question Clarification by joseleon-ga on 01 Oct 2003 01:18 PDT
Hello, binarian:

  This is a small test of what you want, it's an HTML file, called
product.htm, that holds a textfield and a link beside it. When you
click on the link, a new window will open poiting to upload.htm, that
contains a file field and a close link. If you select some file and
click on the close link, the window will close and the contents of the
file field will be set on the parent textfield.
  
  I post this as a request for a clarification to ensure that this is
what you want, once you agree, I will answer the question and we will
start working to adapt it to your scripts.

product.htm
-----------
  
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Documento sin t&iacute;tulo</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//-->
</script>
</head>

<body>
<form action="" method="post" name="form1">
  <input type="text" name="textfield">
  <a href="javascript:MM_openBrWindow('upload.htm','upload','width=300,height=200');">Upload
image</a>
</form>
</body>
</html>
  
upload.htm
----------
  
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Documento sin t&iacute;tulo</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_popupMsg(msg) { //v1.0
  alert(msg);
}

function setValue()
{
  window.opener.document.getElementById('textfield').value=document.getElementById('file').value;
  window.close();
}
//-->
</script>
</head>

<body>
<form name="form1" enctype="multipart/form-data" method="post"
action="">
  <input type="file" name="file">
</form>
<p><a href="javascript:setValue();">Close this window</a></p>
<p>&nbsp;</p>
</body>
</html>


To test it, copy and paste the code for each page on a separate html
file and load product.htm into your browser. Be aware of the word
wrapping that may break some code. If you have problems I will post a
zip with the files.

Regards.

Request for Question Clarification by joseleon-ga on 02 Oct 2003 23:27 PDT
Hello, binarian:
  Did you find useful the code I posted?

Regards.

Clarification of Question by binarian-ga on 03 Oct 2003 17:01 PDT
i was using something similar to that at some point but it got messed
up when i tried to integrate it. however your code does it parse the
url cuz it cant put in the full C:// url it needs just the file name.

if u can integrate it with the code i have posted that would be ideal
but u have the right idea.

Request for Question Clarification by joseleon-ga on 06 Oct 2003 07:32 PDT
Hello, binarian:
  I can strip the filename to include just the filename without the
path, but to integrate the javascript into your code, I would need the
full sources, that is, all the includes that make up your sources, is
that possible?

Regards.

Clarification of Question by binarian-ga on 06 Oct 2003 12:53 PDT
ideally i wouldnt even be using this popup but just do it in one shot
from the record insert page.

feel free to integrate my upload page into the add products page.

i have the pages here.  www.binarian.com/upload.zip

that should be all u need to actually integrate the 2 files. 
that may bypass the whole issue of having that 2nd window. tell me
what you think.

Clarification of Question by binarian-ga on 08 Oct 2003 20:54 PDT
ive actually upped the price.. i need an answer quick. anyone?

Request for Question Clarification by joseleon-ga on 11 Oct 2003 02:26 PDT
Hello, binarian:
  Do you mean to add the file field to the upload products page and
process all the information in a single pass when the user submits the
page? If that's the case, you only need to add the file field on the
products page, change the enctype of the product submit form to
multipart/form-data and process the uploaded field in the same way the
upload_image.asp script does.

To perform these steps for you I would need the full code, including
include files like these:

<!--#include file="../Connections/ncshoes.asp" -->
<!--#include file="../ScriptLibrary/incResizeAddOn.asp" -->
<!--#include file="../ScriptLibrary/incPureUpload.asp" -->

And I also need the database to recreate that part of your web on my
system, the other option is that you send me FTP access to your server
so I can work on it. With FTP access I can finish this project in no
time.

Regards.

Request for Question Clarification by joseleon-ga on 15 Oct 2003 23:40 PDT
Hello, binarian:
  Are you still interested in a solution to this problem? Please, let me know.

Regards.

Clarification of Question by binarian-ga on 16 Oct 2003 06:10 PDT
yes absolutely!

Request for Question Clarification by joseleon-ga on 16 Oct 2003 06:49 PDT
Hello, binarian:
  So please, is there any possibility I can integrate these changes in
the same way we have done with the other answer (stats)? By having
write access to your server, I can tweak very fast all the scripts and
test the results, if you don't trust me, you can check all my previous
answers here:

http://answers.google.com/answers/ratings?user=7908906466083568595

And you can see I have done a lot of similar tasks but having write
access to the server, or at least, being able to reproduce the
customer's page on my system. As a Google Researcher we try to give
always the best service, don't worry ;-)

Regards.

Clarification of Question by binarian-ga on 16 Oct 2003 11:19 PDT
wow u know what..i didnt even know it was you.. yeah sure ill set up
access....ill upload it to your text file upload now!

Clarification of Question by binarian-ga on 16 Oct 2003 11:33 PDT
u have the ftp info now..via that text file upload from the other thing.

Request for Question Clarification by joseleon-ga on 18 Oct 2003 03:56 PDT
Hello, binarian:
  I have been checking all the info you sent me and I have a few
questions:

-I need an user and a password to enter the shop administration to
test if the code I'm writting works

-This question is about to add some javascript to fill a field
dinamically without refresh the page, but now, I think the question is
to integrate some of your code into the administration utility. Is
that correct?

-I need you to send me the exact url of the page you want me to
change, so I modify the code in the right place, just to be sure.

Regards.

Clarification of Question by binarian-ga on 18 Oct 2003 07:38 PDT
u should have it in that txt file upload dir. thanks

Request for Question Clarification by joseleon-ga on 18 Oct 2003 09:06 PDT
Hello, binarian:

  Ok, so you want me to do the following:
  
-Edit the adminprods.asp adding a file field in the new product page
instead the current input field
-Process the post of this page to the server
-Place the uploaded image into the images directories "prodimages"
-Produce a resized image
-Update the database with the path to that image

Is that correct?

Sorry I ask again, but the question has changed very much since the
beginning and I want to be sure what I have to do.

Regards.

Clarification of Question by binarian-ga on 18 Oct 2003 10:11 PDT
that is correct. the include files i have in the origilan code i
posted creates two images. one thumnail and one resize for the
enlarged product image and appends an extension to the thumnail image.
 these include files will handle the resizes and appending for you.
the path will need to be inserted in the database which the code
should also already do in the existing page. integrating the upload
page with adminprods.asp is the task at hand. I will take care of
referencing the separate thumnail image later on. U can examine the
ScriptLibrary dir for the includes that handle all resizing.

hope this is clear. your description was right on track but just
remember their will be 2 images after the upload both of which are
resized.

Request for Question Clarification by joseleon-ga on 20 Oct 2003 03:14 PDT
Hello, binarian:
  After examine the scripts to upload/resize images, I have decided to
just upload the images in the popup window, as you have it, and strip
the uploaded filename to place it in the pLargeImage file field. I
didn't know it was so hard to upload files in ASP, in PHP it's just a
snap because PHP already decodes all the information and places it in
the proper place, without install any additional component and also,
all the request values are available along with the uploaded file.
Please, check it out to see if this is what you want.

Regards.

Clarification of Question by binarian-ga on 20 Oct 2003 06:34 PDT
the method will work but the upload isnt wokring. the moment i click
upload, the flash progress window opens for a splits econd then closes
as does the upload page box itself.. it does put the url as it needs
to be..but does not upload the image...

Request for Question Clarification by joseleon-ga on 20 Oct 2003 07:08 PDT
Hello, binarian:
  I will try to fix the upload part asap, did you write that code?

Regards.

Clarification of Question by binarian-ga on 20 Oct 2003 07:20 PDT
parts of it yes but the framework is open source ASP code with
modifications. hey incidentally ... ill wait for yer message to test
it and if u get done and yer bored..i got another for u if yer
interested. its a quickie.. : )

://www.google.com/answers/threadview?id=267439

Request for Question Clarification by joseleon-ga on 20 Oct 2003 09:01 PDT
Hello, binarian:
  Please, check now if the upload works, uploaded images must be
stored on the prodimages directory. I will check your other answer
later.

Regards.

Clarification of Question by binarian-ga on 20 Oct 2003 11:26 PDT
thumbnails dont seem to be created. only the main image.

Request for Question Clarification by joseleon-ga on 20 Oct 2003 12:40 PDT
Hello, binarian:
  I have fixed it to generate both images, the original and the
resized one, both stored on the prodimages directory, also I have
improved the javascript code to take the "real" uploaded image file
name and put it on the input field, because you have setup the upload
script to resolve name conflicts and create _1, _2, etc if the file
already exists, so after upload, the input field will be filled with
the right value.

Please, test it and tell me if everything works ok.

Regards.

Clarification of Question by binarian-ga on 20 Oct 2003 13:34 PDT
hey one thing.. i went to edit and edit is still the old way. if their
is a link to Upload_image.asp in teh edit area..will it work the same
as regular upload because the edit and insert code is all in the same
place. also if u can get it so that the thumnail record which is
appended _small to the end of file name into the the pImage column
that would make everything good. currnetly pLargeImage is the upload.
I cant append _small to the products.asp include files as i have done
in the past. its just not working that way.  if u want i can increase
the price another $5 bucks or something? im a little strapped. or i
would try to add more.

Request for Question Clarification by joseleon-ga on 20 Oct 2003 13:59 PDT
Hello, binarian:
  Sure, I'm going to help you until you need, this is the spirit of a
Google Researcher and then, you tip the amount you think I deserve, no
problems on that ;-). Also, if you think I have done enough work to
deserve the money, please, let me answer the question before expires
and we will continue working on it using the Request for a
clarification feature. Are you agree?

Regards.

Clarification of Question by binarian-ga on 20 Oct 2003 14:15 PDT
sounds great. if u can get a chance prior to wednesday to look at that
other question as well that i had linked to i would appreciate it as
well! as for this one..go for it. we will clarify as we go on!
Answer  
Subject: Re: pass contents from a file upload upload field to a text field on parent page
Answered By: joseleon-ga on 20 Oct 2003 15:12 PDT
Rated:5 out of 5 stars
 
Hello, binarian:
  Ok, so this what I have done so far:

-I have fixed your upload/resize scripts to put the images in the
right place
-I have also modified them to return information about the newly
uploaded image
-I have taken that info and the upload image field it's set to the
right value, pointing to the uploaded image on the server

Things to do yet:
-Modify the edit product form to have the option to upload images
-Insert the small image also in the database to be used later

Regards.

Request for Answer Clarification by binarian-ga on 20 Oct 2003 15:24 PDT
for the thumbnail..just insert the _small image path in the 'pImage'
column in the products table because the gallery already refernces it
there.

Clarification of Answer by joseleon-ga on 21 Oct 2003 11:58 PDT
Hello, binarian:
  I have added the link to upload images to the edit product page. I
have also modified the script to save into the database, in the pImage
field, the thumbnail filename, so it works now, I have tested it with
the product test1.

Please, tell me if everything it's ok. I begin to look into the other
question.

Regards.

Request for Answer Clarification by binarian-ga on 21 Oct 2003 13:31 PDT
wow all that stuff works great! quick question.. in admincats.asp
where there are necessary image uploads for top category and
subcategory this area also needs a similar integration. i didnt notice
that those were there till just now...!

Clarification of Answer by joseleon-ga on 21 Oct 2003 13:41 PDT
Hello, binarian:
  Where the category images should be uploaded? If it's in a directory
other than prodimages, I would need to modify the upload script and
the upload page to upload images in a directory other than prodimages,
it's not a quick question ;-)

Regards.

Request for Answer Clarification by binarian-ga on 23 Oct 2003 08:46 PDT
i havent forgotten about this .. the other thing just takes precedence
for now . i will have time for this by monday! thanks for your help so
far!

Clarification of Answer by joseleon-ga on 25 Oct 2003 01:23 PDT
Hello, binarian:
  I wait until you send me more info.

Regards.
binarian-ga rated this answer:5 out of 5 stars

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy