Passing request of file input type to a jsp
Hi i m using this script for file uploading the form is.... <html > <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <form action="uploadscript.jsp" name="filesForm" enctype="multipart/form-data" method="post">
Please specify a file, or a set of files:
<input type="file" name="userfile_parent" value="userfile_parent" >
<input type="submit" value="submit" value="Send">
</form> </body> </html> And i am tring to get the url on uploadscript.jsp by using String parentPath=request.getParameter("userfile_parent"); but i foud that its value is NULL it is not working what should i do to get the userfile_parent on uploadscript.jsp help me!!! Message was edited by: UDAY Message was edited by: UDAY
avajain
Posts: 135
From: Noida , India
Registered: 5/10/06
Read Re: Passing response but getting NULL
Posted: Sep 20, 2006 2:43 AM in response to: UDAY in response to: UDAY
Click to reply to this thread Reply
Use method="GET" in place of method="post" .
Thanks
UDAY
Posts: 26
From: JAIPUR
Registered: 8/14/06
Read Re: Passing response but getting NULL
Posted: Sep 20, 2006 3:18 AM in response to: avajain in response to: avajain
Click to edit this message... Click to reply to this thread Reply
now it is giving this error message by e.getMessage()
[br]the request doesn't contain a multipart/form-data or multipart/mixed stream, content type header is null
the uploadscript is this....
http://www.one.esmartstudent.com
can u please help me.
Here is sample code which we have used in one of our projects with org.apache.commons.fileupload.*.
You can find String fullName = (String) formValues.get("FULLNAMES"); at the end that gives name of file.
<%@ page import="java.util.*"%>
<%@ page import="java.util.List"%>
<%@ page import="java.util.Iterator"%>
<%@ page import="java.io.File"%>
<%@ page import="java.io.*"%>
<%@ page import="org.apache.commons.fileupload.*"%>
<%@ page import="org.apache.commons.fileupload.disk.*"%>
<%@ page import="org.apache.commons.fileupload.servlet.*"%>
<%!
//method to return file extension
String getFileExt(String xPath){
//Find extension
int dotindex = 0; //extension character position
dotindex = xPath.lastIndexOf('.');
if (dotindex == -1){ // no extension
return "";
int slashindex = 0; //seperator character position
slashindex = Math.max(xPath.lastIndexOf('/'),xPath.lastIndexOf('\\'));
if (slashindex == -1){ // no seperator characters in string
return xPath.substring(dotindex);
if (dotindex < slashindex){ //check last "." character is not before last seperator
return "";
return xPath.substring(dotindex);
%>
<%
Map formValues = new HashMap();
String fileName = "";
boolean uploaded = false;
// Check that we have a file upload request
boolean isMultipart = FileUpload.isMultipartContent(request);
//Create variables for path, filename and extension
String newFilePath = CoeResourceBundle.getEmailProperties("FILE_UPLOAD_PATH");//application.getRealPath("/")+"temp";
String newFileName ="";
String FileExt = "";
//System.out.println(" newFilePath"+newFilePath+"/");
//out.println(" newFilePath"+newFilePath+"<br>");
// Create a factory for disk-based file items
FileItemFactory factory = new DiskFileItemFactory();
// Create a new file upload handler
ServletFileUpload upload = new ServletFileUpload(factory);
// Parse the request
List /* FileItem */ items = upload.parseRequest(request);
// System.out.println(" newFilePath"+newFilePath+"/");
// Process the uploaded items
Iterator iter = items.iterator();
//Form fields
while (iter.hasNext()) {
//System.out.println("in iterator");
FileItem item = (FileItem) iter.next();
if (item.isFormField()) {
String name = item.getFieldName();
String value = item.getString();
if (name.equals("newFileName")) {
newFileName = value;
//System.out.println("LOADING");
formValues.put(name,value);
else {
//System.out.println("in iterator----");
String fieldName = item.getFieldName();
fileName = item.getName();
int index = fileName.lastIndexOf("\\");
if(index != -1)
fileName = fileName.substring(index + 1);
else
fileName = fileName;
FileExt = getFileExt(fileName);
String contentType = item.getContentType();
boolean isInMemory = item.isInMemory();
long sizeInBytes = item.getSize();
if (fileName.equals("") || sizeInBytes==0){
out.println("Not a valid file.<br>No upload attempted.<br><br>");
} else {
// out.println("ACTUAL fileName= " newFilePath"\\"+fileName+ "<br>");
//File uploadedFile = new File(newFilePath+"\\", newFileName+FileExt);
File uploadedFile = new File(newFilePath+"/",fileName);
File oldFile = new File(CoeResourceBundle.getEmailProperties("FILE_UPLOAD_PATH")+"/"+fileName);
File oldFileApproved = new File(CoeResourceBundle.getEmailProperties("APPROVED_FILE_LOCATION")+"/"+fileName);
try{
if (!oldFile.exists()&&!oldFileApproved.exists())
item.write(uploadedFile);
uploaded = true;
//out.println(fileName+" was successfully uploaded as "+ newFileName+FileExt +".<br><br>");
catch (java.lang.Exception e) {
out.println("Errors prevented the file upload.<br>"+fileName+ " was not uploaded.<br><br>");
String userid = (String) formValues.get("USERID");
String fullName = (String) formValues.get("FULLNAMES");
String email = (String) formValues.get("EMAILID");
String empno = (String) formValues.get("EMPNO");
String docType = (String) formValues.get("DOCTYPE");
String desc = (String) formValues.get("MYTEXT");
String title = (String) formValues.get("TITLEBOX");
String module = (String) formValues.get("MODULE");
String techfunctype = (String) formValues.get("TECHFUNCTYPE");
%>
Similar Messages
-
Upload file input type="hidden" to server
I have a file that is on a user machine. The file is always in the same location. I want to have the user click on an upload button without selecting a file and have it sent to the server for processing. I have tried to use <input type="hidden" name="fileupload" value="c:\filepath">. When I run it this way I get no file found. Please help!
I am sorry, I will move it. Didn't notice it was in Acrobat, I was wanting Coldfusion.
Edit: Since I am unaware of how to move it I'm just going to mark it as answered. -
FireFox v22 - File Input type now shows browse on left
For some unknown reason, Firefox v22 has moved the BROWSE button on an <INPUT type="file" statement.
The Browse button appears on the left hand side - this has previously only happened in Webkit based browsers.
I can force the button to the right hand side in webkit browsers by using:
input[type="file"].file::-webkit-file-upload-button {
float: right;
position: relative;
top: -1px;
right: -90px;
However, I can't find any similar means of adjusting the layout in Firefox.I honestly think the file input is something that Internet Explorer (still) and previous FF had right and that Safari and Chrome have wrong. Styling the colour of text for inputs is now going to be a real problem - and when you have to tell the whole world how to cope with something, that's as real a problem as a doubled margin on a float was/is in IE6 - because the text color shown inside the box of a text input is also the text colour that is shown outside the box on a file input. Black text on a black background?
If you are here, World, the solution is to put a background-color on all your inputs e.g. input {background-color: #FFF} .
The new input also removes the option to copy/paste link values, which can be a real pain if you are doing a lot of file uploading e.g. of photos identified by (long links with...) productids -
Passing correct image-file path in flashVar from jsp into embedded Flex application
I have an application that embeds an image viewer, written in
Adobe Flex within a jsp page running in a J2EE application on
Tomcat 5.5. The Flex code is a one-line modification of the
application displayed at (
http://www.adobe.com/devnet/flex/samples/fig_panzoom/).
The image viewer is founded and loaded in the output to the
screen, but I cannot get the Image Viewer to display the image
correctly, even though I succeed when either I run the .swf from
the command-line or from an HTML page.
My webapp is called FRSApp. The directory structure is, under
FRSApp:
myTest.html
jsp/catalog.jsp
pan_zoom_files/images/map.jpg
The JSP code is thus,
code:
<%@ taglib prefix="mm" uri="FlexTagLib" %>
<mm:mxml
source="../pan_zoom_files/FIG_PanZoom_for_jsp.mxml" >
<mm:flashvar name="myVar"
value="/FRSApp/pan_zoom_files/images/map.jpg"/>
</mm:mxml>
the code within PanZoom.mxml is,
private var _imageURL:String =
Application.application.parameters.myVar;
<ns1:ImageViewer
id="imageViewer"
imageURL="{ _imageURL }"
bitmapScaleFactorMax="5"
bitmapScaleFactorMin=".05"
width="100%" height="100%"
x="0" y="0"/>
I have tried other paths to the image file, including
images/map.jpg [required by command-line execution of .swf]
pan_zoom_files/images/map.jpg [required by HTML page
(myTest.html) that embeds the .swf file]
I have succeeded in loading image viewer embedded in the jsp
page when the image path is hard-coded in the mxml file, by means
of the following code:
<div id="swf-id" class="swfcontent"><embed
type="application/x-shockwave-flash"
src="../pan_zoom_files/FIG_PanZoom_for_jsp.swf" id="swf-id"
name="swf-id" bgcolor="#ffffff" quality="high" wmode="opaque"
height="480" width="772"></div>
<script type="text/javascript">
// <![CDATA[
var props = new Object();
props.swf = "../pan_zoom_files/FIG_PanZoom_for_jsp.swf";
props.id = "swf-id";
props.w = "772";
props.h = "480";
props.ver = "9";
props.wmode= "opaque";
var swfo = new SWFObject( props );
registerSWFObject( swfo, "swf-id" );
// ]]>
</script>
The error is either a "failed to load image" generated by the
Image Viewer code, or a Flex system error message, resembling a
null-pointer exception:
TypeError: Error #1009: Cannot access a property or method of
a null object reference.
at FIG_PanZoom_for_jsp()
at _FIG_PanZoom_for_jsp_mx_managers_SystemManager/create()
at mx.managers::SystemManager/initializeTopLevelWindow()
at mx.managers::SystemManager/docFrameHandler()
Any ideas are greatly appreciated!!Solved the problem. I had made several mistakes. One of them
was to pass in the J2EE context path when what was needed was the
fully qualified image url:
http://localhost/FRSApp/pan_zoom_files/images/earth-map_small.jpg.
The second mistake was to assume the flashvar variable could be
picked up by initializing Action Script in the the mxml file,
designated by <mx:script> tags. No, the flash variable will
only be visible within the <mx:Application>
</mx:Application> tags. -
dear all,
anybody know how to transfer the the value from <input type="file"> when it
posted to it self (like as modify form).
sample:
self.jsp
<form action="self.jsp">
<input type="file" name="files"
value="<%=request.getParameter("files")%>">
<input type=submit name="go">
</form>
First your form enctype must be "multipart/form-data" ..
Second there should be a service (java class or something) running on the server
that can read the servlet input stream and upload.
My Question ..Could you ever display value in file object's text field ?? I couldn't!
"newsgroup.bea.com" <[email protected]> wrote:
>dear all,
>
>anybody know how to transfer the the value from <input type="file"> when
>it
>posted to it self (like as modify form).
>
>sample:
>self.jsp
><form action="self.jsp">
> <input type="file" name="files"
>value="<%=request.getParameter("files")%>">
> <input type=submit name="go">
></form>
>
>
>
>
-
Use of input type="file"
Hellow
How can I use the HTML tag <input type="file" > in jsp/servlets ?
how can I got the file and saving it?Take a look at this page: http://search.java.sun.com/search/java/?qt=jsp+upload&x=39&y=6 - it is a search page and you can use it to find whether or not anyone has asked the question you have before. Often you will find that the question you have asked has been asked before, sometimes as much as 29000 times. It is quicker than asking a question for the first time because you don't have to wait for replies. - they are already there. I also believe that if you don't know understand search engines you are unlikely to understand Java.
To help with your search you may want to know that the "file" input type creates a Multipart request and that the term "com.oreilly.servlets" may well be relevant too. -
Getting parameters from text and file input tag. . canyou help me ?
Hello!
Is there anyway of getting parameters from an
text field input in a form like :
<form name="signinForm" method="post" action="uploadFile.jsp" enctype="multipart/form-data" >Actually I would like to insert the parameters and make the upload of an file
on the same form. It is something likethis :
Form.jsp
<form name="signinForm" method="post" action="uploadFile.jsp" enctype="multipart/form-data" >
<input type="text" id="name" name="signinName" />
<input name="signinFile" id="fileUp" type="file" />
<input type="submit" id="submit_btn" name="signinSubmit"/>uploadingFile.jsp
<%@ page import="java.io.*,javax.servlet.http.HttpServletRequest,javax.servlet.ServletInputStream" %>
<%@ page import="java.io.FileWriter,java.io.IOException" %>
<%
.//upload the file
String email = request.getParameter("signinName").trim(); //this line is bringing me an NullPointerException
%>Thanks in advance for any suggestion!!
All the best!You cannot use the HttpServletRequest object to retrieve parameters from a multipart form. You'll have to use a package that can parse such a form. I suggest Apache commons FileUpload.
http://jakarta.apache.org/commons/fileupload/
Using this package you can get both the file upload and any other parameters. -
Php form, input type country
Is it important to have a country of origin? If so, do I just
type Greece?
<input type=hidden value="GREECE"
name=originating_country>
JoAnd who wrote jomail.php? You? Can you show us the code in
it?
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go
- DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs,
Tutorials & Resources
==================
"josie1one" <[email protected]> wrote in message
news:[email protected]...
> Sorry, should have looked
>
> action="jomail.php"
>
> --
> Jo
>
>
>
> "Murray *ACE*" <[email protected]>
wrote in message
> news:[email protected]...
>>>>"action"
>>>
>>> POST
>>
>> No, that's METHOD. What's the "action" attribute's
value?
>>
>> --
>> Murray --- ICQ 71997575
>> Adobe Community Expert
>> (If you *MUST* email me, don't LAUGH when you do
so!)
>> ==================
>>
http://www.projectseven.com/go
- DW FAQs, Tutorials & Resources
>>
http://www.dwfaq.com - DW FAQs,
Tutorials & Resources
>> ==================
>>
>>
>> "josie1one" <[email protected]> wrote
in message
>> news:[email protected]...
>>> No, no database. Yes, processed to produce a
summary mesage and emailed
>>> to the site's owner. No, the owner isn't asking
for the country of
>>> origin. The purpose is an enquiry form for
holiday apartments to let.
>>>
>>>>"action"
>>>
>>> POST
>>>
>>> --
>>> Jo
>>>
>>>
>>>
>>> "Murray *ACE*"
<[email protected]> wrote in message
>>> news:[email protected]...
>>>> So the form's data is not captured in a
database? It's only processed
>>>> to produce a summary message and emailed to
the site's owner? Is the
>>>> owner asking for the Country of origin?
>>>>
>>>> What is the value of the "action" attribute
of the <form> tag?
>>>>
>>>> --
>>>> Murray --- ICQ 71997575
>>>> Adobe Community Expert
>>>> (If you *MUST* email me, don't LAUGH when
you do so!)
>>>> ==================
>>>>
http://www.projectseven.com/go
- DW FAQs, Tutorials & Resources
>>>>
http://www.dwfaq.com - DW FAQs,
Tutorials & Resources
>>>> ==================
>>>>
>>>>
>>>> "josie1one" <[email protected]>
wrote in message
>>>> news:[email protected]...
>>>>> Thanks for the reference, lovely quote
(o:
>>>>>
>>>>> I guess I don't need that information
but I didn't know if it was
>>>>> needed.
>>>>>> how is that information then
handled?
>>>>>
>>>>> php and erm, passed to a mail handler
which processes a thank you. Is
>>>>> that the correct answer?
>>>>>
>>>>>> By the way, all attribute values
should be in quotes -
>>>>>>
>>>>>> <input type="hidden"....
>>>>>
>>>>> Thank you, I will fix that.
>>>>>
>>>>> --
>>>>> Jo
>>>>>
>>>>>
>>>>>
>>>>> "Murray *ACE*"
<[email protected]> wrote in message
>>>>>
news:[email protected]...
>>>>>> Why are you feeling it would matter.
Do *you* need that information?
>>>>>> If not, then it's like what the
Cheshire Cat said to Alice....
>>>>>>
>>>>>> Alice: [standing at fork in road]
Which way do I go?
>>>>>> Cat: What is your destination?
>>>>>> Alice: It doesn't matter.
>>>>>> Cat: Then it doesn't matter which
way you go!
>>>>>>
>>>>>> Those fields are there only for the
support of the processing script,
>>>>>> and for the way that the information
is handled. What script are you
>>>>>> using and how is that information
then handled?
>>>>>>
>>>>>> By the way, all attribute values
should be in quotes -
>>>>>>
>>>>>> <input type="hidden"....
>>>>>>
>>>>>> --
>>>>>> Murray --- ICQ 71997575
>>>>>> Adobe Community Expert
>>>>>> (If you *MUST* email me, don't LAUGH
when you do so!)
>>>>>> ==================
>>>>>>
http://www.projectseven.com/go
- DW FAQs, Tutorials & Resources
>>>>>>
http://www.dwfaq.com - DW FAQs,
Tutorials & Resources
>>>>>> ==================
>>>>>>
>>>>>>
>>>>>> "josie1one"
<[email protected]> wrote in message
>>>>>>
news:[email protected]...
>>>>>>> Sorry Micha, that wasn't enough
was it?
>>>>>>> It's an input form - I can't
show the link because I have a
>>>>>>> scripting error, but the
relevant lines are these:
>>>>>>>
>>>>>>> <form name="form1"
method="post" action="jomail.php">
>>>>>>> <input type=hidden
value="General Information Request"
>>>>>>> name=mailsubject>
>>>>>>> <input type=hidden
value="kiwiannes-leros.com"
>>>>>>> name=originating_site>
>>>>>>> <input type=hidden value="UK"
name=originating_country>
>>>>>>> <input type=hidden
name="env_report"
>>>>>>>
value="REMOTE_HOST,REMOTE_ADDR">
>>>>>>> <input type=hidden
value="Information Request" name=title>
>>>>>>>
<fieldset><legend><strong>Contact
Form</strong></legend>
>>>>>>>
>>>>>>> line 4 above - the originating
country is Greece. What do I type
>>>>>>> please? GR, Greece, GREECE - and
does it matter?
>>>>>>>
>>>>>>> --
>>>>>>> Jo
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> "Michael Fesser"
<[email protected]> wrote in message
>>>>>>>
news:[email protected]...
>>>>>>>> .oO(josie1one)
>>>>>>>>
>>>>>>>>>Is it important to have a
country of origin?
>>>>>>>>
>>>>>>>> For what?
>>>>>>>>
>>>>>>>>>If so, do I just type
Greece?
>>>>>>>>>
>>>>>>>>><input type=hidden
value="GREECE" name=originating_country>
>>>>>>>>
>>>>>>>> It all depends on the
server-side script. This hidden field alone
>>>>>>>> in the
>>>>>>>> HTML means absolutely
nothing.
>>>>>>>>
>>>>>>>> Micha
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>
>>>
>>
>
> -
Passing Request Parameters to Non JSF Page
I want to pass request parameters from a JSF page (Page1.jsp) to a non JSF page (paramTest.jsp) and am having trouble.
The parameters are 'null' in the non JSF page.
Here is code (in Page1.java) that is called when 'button1' is clicked in Page1.jsp (modified from JSF, Bergsten p.167):
public String button1_action() {
FacesContext context = javax.faces.context.FacesContext.getCurrentInstance();
ExternalContext ec = context.getExternalContext();
try {
ec.redirect("http://xxx/paramTest.jsp");
} catch (Exception e) {
// print exception information in the server log
log("Exception occurred when redirecting page", e);
error("Trouble redirecting page");
return null;
context.responseComplete();
return "success";
}Here is Page1.jsp code: <?xml version="1.0" encoding="UTF-8"?>
<jsp:root version="1.2" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page">
<jsp:directive.page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"/>
<jsp:text><![CDATA[
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
]]></jsp:text>
<f:view>
<html lang="en-US" xml:lang="en-US">
<head>
<meta content="no-cache" http-equiv="Cache-Control"/>
<meta content="no-cache" http-equiv="Pragma"/>
<title>Page1 Title</title>
<link href="resources/stylesheet.css" rel="stylesheet" type="text/css"/>
</head>
<body style="-rave-layout: grid">
<h:form binding="#{Page1.form1}" id="form1">
<h:inputText binding="#{Page1.name}" id="name" style="left: 144px; top: 96px; position: absolute"/>
<h:outputLabel binding="#{Page1.componentLabel1}" for="componentLabel1" id="componentLabel1" style="left: 72px; top: 96px; position: absolute">
<h:outputText binding="#{Page1.componentLabel1Text}" id="componentLabel1Text" value="Name:"/>
</h:outputLabel>
<h:commandButton action="#{Page1.button1_action}" binding="#{Page1.button1}" id="button1" onclick="this.form.submit() style="left: 120px; top: 144px; position: absolute" value="Submit"/>
<h:messages binding="#{Page1.messageList1}" errorClass="errorMessage" fatalClass="fatalMessage" id="messageList1" infoClass="infoMessage"
showDetail="true" style="left: 480px; top: 72px; position: absolute" warnClass="warnMessage"/>
</h:form>
</body>
</html>
</f:view>
</jsp:root>Here is the rendered Page1.jsp html: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xml:lang="en-US" lang="en-US">
<head>
<meta http-equiv="Cache-Control" content="no-cache"/><meta http-equiv="Pragma" content="no-cache"/>
<title>Page1 Title</title>
<link type="text/css" rel="stylesheet" href="resources/stylesheet.css"/>
</head>
<body style="-rave-layout: grid">
<form id="form1" method="post" action="/cenwkd/faces/Page1.jsp;jsessionid=79A5577F53DAAEDF164C5D33F33D8327" enctype="application/x-www-form-urlencoded">
<input id="form1:name" type="text" name="form1:name" style="left: 120px; top: 96px; position: absolute" />
<label id="form1:componentLabel1" for="form1:componentLabel1" style="left: 72px; top: 96px; position: absolute">
<span id="form1:componentLabel1Text">Name:</span></label>
<input id="form1:button1" type="submit" name="form1:button1" value="Submit" onclick="" style="left: 120px; top: 144px; position: absolute" />
<input type="hidden" name="form1" value="form1" />
</form>
</body>
</html> Here is the source for a test jsp, paramTest.jsp: <html>
<head>
<title>
paramTest
</title>
</head>
<body>
<h2><%= request.getParameter("form1:name")%></h2>
<%-- Also tried: request.getParameter("name"), "name" is the original 'id' value for the text field entered in Creator
it apparently is changed to "form1:name" when the html is rendered--%>
</body>
</html>Here is the rendered html from paramTest.jsp: <html>
<head>
<title>
paramTest
</title>
</head>
<body>
<h2>null</h2>
</body>
</html>Any help would be much appreciated.Hi,
I dont see any parameters that you are trying to pass in the below code.
public String button1_action() {
FacesContext context = javax.faces.context.FacesContext.getCurrentInstance();
ExternalContext ec = context.getExternalContext();
try {
ec.redirect("http://xxx/paramTest.jsp");
} catch (Exception e) {
// print exception information in the server log
log("Exception occurred when redirecting page", e);
error("Trouble redirecting page");
return null;
context.responseComplete();
return "success";
} -
Save a file that I upload via JSP
hello friends,
I have a JSP page that use a file input type. this is ok.
the form is: <form action="/alta" method="post" enctype="multipart/form-data">
this work fine.
but i need save this upload file to a filesystem... (windows)
some idea... i search in google but not found nothing.
thanks in advance.
Gustavo VilladaHi jeffrey sg,
When you convert a file, it's automatically stored in your Acrobat.com online account. You can download your files by following these steps:
Log in to your account at https://cloud.acrobat.com/files.
Select the file or files that you want to download.
Click Download at the top of the Files list. Your files will be downloaded to the Downloads folder on your computer.
Please let us know how it goes.
Best,
Sara -
I've had the <input type="file"> ... <cffile ...> thing going for a few years now.
There is a database where the uploaded file names are stored once the files are uploaded to the server. It sees things in terms of problems and stores uploaded file name accordingly with the ProbID prepended onto the file name; e.g., MyPicture.jpg would end up in the designated directory and databawe as P416_MyPicture.jpg. This allows user to store pictures with the same name in different problems without a conflict. There has been an issue with certain characters (e.g., spaces, +, #, etc.) causing problems when they are in file names so we have come up with a way using the <cffile ... rename> to replace these chars with _. This means that MyPic+.jpg would end up being P416_MyPic_.jpg.
This is where the problem appears. If someone were to upload MyPic+.jpg after someone else uploaded MyPic_.jpg in the same problem, then the + file would overwrite the _ file before the system knew they had a problem. And there is now way to restore the original file without going to the system backup and doing so – which is a whole other story … especially, if the person doesn’t tell anyone.
The logical solution would be to be able to test the new final file name (the name after making the substitutions mentioned above) against the existing files in the database before you went from the page where the <input type=file> control to the associated _action.cfm page where the <cffile> object is located. Given that this seems to be the province of Ajax, this would seem like a natural use of the really interesting technology. I have can determine the file name from the onChange action on the <input type=File> so that this would be the place for Ajax to come to the rescue by looking up the final file name and then letting the user know whether the resultant name is a unique within the database or not. If so, I'll just enable the Add button which sets right next to the <input > control and let them upload it. If not, I'll put up an error message telling them that this file already exists in the system.
This would be the perfect solution. It would let me do some Ajax stuff like I've wanted to do for the past year, but never have had the time to do because this is the project that won't go away. This is, in fact, the last thing of any consequence that remains to do on this 2-1/2 year nightmare – be careful what you wish for. If I can get this done this week, then maybe I can finally take a weekend off … maybe it will finally come to an end.
Which finally leads to my question: I'm looking for some tips on how to get this thing going since I can barely spell Ajax. I've got a book and looked at some stuff online about CF and Ajax, but a good example or two or three would be worth a day's worth of poking around on the web and in my books.
Thanks in advance for any suggestions, ideas, help, whatever.
LenAdam,
Thank you for your suggestion, but, after spending the night working with Ben Forta's CF8, vol 2, Chap 34, working with <cfajaxproxy>, I was able to do exactly what I wanted and it appears, after some testing, to work exactly as I had envisoned it should.
I am now calling a JavaScript function (testFileName) from the onChage event on the <input type="file"> or Browse button, which calls my proxy.cfc that contains the server side of the equation. This funciton testFileName (I've run out of cleaver function/file names). The query contained therein hits the database to see if the passed in parameters can pull up an existing file. If they do, the particulars (file name, data attahced, etc.) are returned to the JavaScipt procedure that puts up the error notice. The user can then chose to either overwrite the file or quit. Quiting leaves the your on the Attachment PopUp where he/she started with nothing being uploaded.
Thanks again for your suggestion. I appreciate your taking the time to do so.
Len -
Can't get parameter in struts when using input type="file"...?
Hi everyone:
Can the common html tag and struts tag be used together?I have an example:in jsp
<html:form method="post" action="sendmail.do" enctype="multipart/form-data">
<tr><td>MailTo:</td><td>
<html:text property="mailto"/></td></tr>
<tr><td>MailFrom:</td><td>
<html:text property="mailfrom"/></td></tr>
<tr><td>Subject:</td><td>
<html:text property="title"/></td></tr>
<tr><td>Content:</td><td>
<html:textarea property="content" rows="7" cols="30"/></td></tr><tr><td>
Attach:</td><td>
<input type="file" name="myfile"/></td></tr><tr><td>
<html:submit/><html:reset/>
</td></tr>
</html:form>
In Action,I want to use the code "request.getParameter("myfile")" to get the file real path.But I always get "null".Why "request.getParamter("myfile")" is null although I choose a file in jsp?
Can struts Tag and html Tag be use together?ThksInstead of the Request, you need to use MultiPart request in this case.
This is because of the following statement you are using in the form tag. {enctype="multipart/form-data"}
Hope it helps.... -
Uploading a file using input type=file
Hi,
I'm not sure if I'm in the right place or not. If not can you please let me know where to find and answer for my question.
I'm trying to upload a file in oracle self-service (online page) and I found that the input type=file will let me select the file so I place the input type inside my htp.formopen command.
I used the following when opening the formopen
htp.formOpen(my_link, 'post',null, 'multipart/form-data');
then I created the <input type="file"> tag
But when I send the link to my second page to see if the input type works I get the page not found error.
I'm thinking that maybe is because my 2nd page doesnt have a parameter that will hold the file but right now I'm not sure how to declare the file variables.
Do you have any idea what could be wrong?
ThanksWhat does your form do when you submit it? Handling file uploads is a bit of a convoluted process. I'd recommend starting here for some guidance:
http://docs.oracle.com/cd/B14099_19/web.1012/b14010/concept.htm#i1005985 -
From browse button of input type=file, can I show the content of a file
Hi all,
I am using, input type=file, where browse button appears. I am having a text area. My requirement is after I select the browse button, I need to show the content of the file in the text area. As of now I 've handled by having another button 'show', which should be pressed after browse done. But, How to handle it in the browse button itself, how will I get that action event from browse button. Plz help.
Regards,
SamI think someone asked a very similar question here,
http://forum.java.sun.com/thread.jsp?forum=45&thread=501889
check the thread, it may help you.
-S- -
How to get the path of input type="file" tag
-- im using <input type="file"> tag to get an input file from a local host, it returns only the filename but not the complete path of the filename,,,
-- i need to know on how to get the compelete path /directory of the filename using <input type="file"> tag , or is there any other way to get an input file from a local host aside from <input type="file"> tag?
thankshttp://msdn.microsoft.com/workshop/author/dhtml/reference/objects/input_file.asp?frame=true
When a file is uploaded, the file name is also submitted. The path of the file is available only to the machine within the Local Machine security zone. The value property returns only the file name to machines outside the Local Machine security zone. See About URL Security Zones for more information on security zones.
i need to know on how to get the compelete path /directory of the filename
using <input type="file"> tag You can't. Its a security thing.
is there any other way to get an input file from a local host aside from <input type="file"> tag?No. Not using just html.
You could always go into activex components, but thats different again.
Cheers,
evnafets
Maybe you are looking for
-
Interactive Services Detection C:\Windows\system32\TSAPPCMP.DLL
I can't find anything on this. I can find a lot dealing with the spoolsv.exe, but nothing on TSAPPCMP.DLL. I am not looking for answers, I am just looking for troubleshooting methods to figure out what is going on. Any guidance would be greatly ap
-
AE is green and seen but can't connect PPPoE
My ae light is green, the network sees it but can't connect to the net. The isp is fine if i plug the wire into the machine, it works. The settings for the airport are identical to the wired. i've downgraded from 6.2 to 6.11 but still no connection.
-
Can no longer change bit rate in AAC custom import setting
I want to change personal settings of AAC, but I can't. Still only the last setting, that was 192 Kbps Stereo. My iTunes version is 10.7
-
Can we make the weblogic look at custom table for emailid
Hi, I am implementing the SQL based provider for weblogic. I want the weblogic look for email id of the user in the same custom table for sending notifications. Is it possible ? By defualt I think weblogic maintains some attributes for user, email id
-
Hello Experts, I have the following issue: I have defined process instruction category Z1 for reading data from OPC server with the following characteristics: 10 PPPI_DATA_ACCESS Manufacturing Data Access 20 PPPI_BUTTON_TEXT HOW MUCH?