UIX Upload File
Hi
I've tried to upload a file using UIX Servlet.
I had used code from UIX Developer Guild and it's success .
Now I want to know How to check whether the file name being upload from user already exits in the target folder on my server. And I also want to know how to alert user via javascript's popup , I means how to use javascript and UIX in combination
Could you please give me some idea ?
Thanks
Attila -
Assuming you are using uiXML - check out the "Multipart requests" section in the JavaDoc for the oracle.cabo.servlet.AbstractPageBroker. The gist of it is that you'll want to create an extension of UIXPageBroker which overrides doUploadFile() and uses the MultipartFormItem API to get at the contents of the uploaded file.
If you are using UIX JSP, you can use the oracle.cabo.share.util.MutlipartFormHandler to explicitly process your multipart requests.
And of course, you'll want to include a fileUpload component in your UIX document - and be sure to set the "usesUpload" attribute of your UIX form to true.
Andy
Similar Messages
-
UIX XML & Download Of Uploaded Files.txt
What is the right way (in UIX XML) to show the content of an uploaded file (retrieving it from a BC4J component)?
Documentation, Samples?your question is rather vague; are you asking how to handle a fileUpload using the UIX controller? Please see the javaDoc for the class
oracle.cabo.servlet.AbstractPageBroker -
Help: How can I implement upload file in UIX ...
without interMedia option.
Can anybody help me?
Thanks!Attila -
Assuming you are using uiXML - check out the "Multipart requests" section in the JavaDoc for the oracle.cabo.servlet.AbstractPageBroker. The gist of it is that you'll want to create an extension of UIXPageBroker which overrides doUploadFile() and uses the MultipartFormItem API to get at the contents of the uploaded file.
If you are using UIX JSP, you can use the oracle.cabo.share.util.MutlipartFormHandler to explicitly process your multipart requests.
And of course, you'll want to include a fileUpload component in your UIX document - and be sure to set the "usesUpload" attribute of your UIX form to true.
Andy -
We can use JSR-168 JPS portlet upload file,
We can use JSR-168 JPS portlet upload file,
here is the source for you referrence:
upload file can use JSR168 portlet,
1,CustomizablePortlet.java File
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ResourceBundle;
import javax.portlet.*;
import oracle.webdb.utils.SimpleStringBuffer;
public class CustomizablePortlet extends GenericPortlet {
private static final String TITLE_KEY = "title";
protected static final String OK_ACTION = "ok_action";
protected static final String APPLY_ACTION = "apply_action";
protected static final PortletMode PREVIEW_MODE = new PortletMode("preview");
protected static final PortletMode EDIT_DEFAULTS_MODE = new PortletMode("EDIT_DEFAULTS");
protected static final PortletMode ABOUT_MODE = new PortletMode("ABOUT");
public CustomizablePortlet() {
public String getTitle(RenderRequest request) {
return request.getPreferences().getValue("title", getPortletConfig().getResourceBundle(request.getLocale()).getString("javax.portlet.title"));
public void doEdit(RenderRequest request, RenderResponse response) throws PortletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.print("<FORM ACTION=\"");
out.print(getEditFormSubmitURL(request, response));
out.println("\" METHOD=\"POST\">");
out.println("<TABLE BORDER=\"0\">");
out.println("<TR>");
out.println("<TD WIDTH=\"20%\">");
out.println("<P CLASS=\"portlet-form-field\" ALIGN=\"RIGHT\">Title:");
out.println("</TD>");
out.println("<TD WIDTH=\"80%\">");
out.print("<INPUT CLASS=\"portlet-form-input-field\" TYPE=\"TEXT\" NAME=\"");
out.print("title");
out.print("\" VALUE=\"");
out.print(getTitle(request));
out.println("\" SIZE=\"20\">");
out.println("</TD>");
out.println("</TR>");
out.println("<TR>");
out.println("<TD COLSPAN=\"2\" ALIGN=\"CENTER\">");
out.print("<INPUT CLASS=\"portlet-form-button\" TYPE=\"SUBMIT\" NAME=\"");
out.print("ok_action");
out.print("\" VALUE=\"OK\">");
out.print("<INPUT CLASS=\"portlet-form-button\" TYPE=\"SUBMIT\" NAME=\"");
out.print("apply_action");
out.print("\" VALUE=\"Apply\">");
out.println("</TD>");
out.println("</TR>");
out.println("</TABLE>");
out.println("</FORM>");
protected String getEditFormSubmitURL(RenderRequest request, RenderResponse response) {
return response.createActionURL().toString();
public void doHelp(RenderRequest request, RenderResponse response) throws PortletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.print("Help for <i><b>");
out.print(getTitle(request));
out.println("</b></i>.");
public void doAbout(RenderRequest request, RenderResponse response) throws PortletException, IOException {
String aboutHTML = (new SimpleStringBuffer(30)).append("/about_").append(getPortletName()).append(".html").toString();
PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher(aboutHTML);
response.setContentType("text/html");
if(rd != null) {
rd.include(request, response);
} else {
PrintWriter out = response.getWriter();
out.print("<p class=\"portlet-font\">This is the about page for ");
out.print(getTitle(request));
out.print(".</p><p class=\"portlet-font\">");
out.print("To customize the contents of this page, create a file named '");
out.print(aboutHTML.substring(1));
out.print("' in the Portlet web application's root directory containing HTML ");
out.print("to appear here. ");
out.print("Alternatively, override the <code>CustomizablePortlet</code> ");
out.println("class's <code>doAbout()</code> method.</p>");
public void doDispatch(RenderRequest request, RenderResponse response) throws PortletException, IOException {
WindowState state = request.getWindowState();
if(!state.equals(WindowState.MINIMIZED)) {
PortletMode mode = request.getPortletMode();
if(mode.equals(PREVIEW_MODE))
doView(request, response);
else
if(mode.equals(EDIT_DEFAULTS_MODE))
doEdit(request, response);
else
if(mode.equals(ABOUT_MODE))
doAbout(request, response);
else
super.doDispatch(request, response);
} else {
super.doDispatch(request, response);
public void processAction(ActionRequest request, ActionResponse actionResponse) throws PortletException, IOException {
String newTitle = request.getParameter("title");
PortletPreferences prefs = request.getPreferences();
prefs.setValue("title", newTitle);
prefs.store();
if(request.getParameter("ok_action") != null) {
actionResponse.setPortletMode(PortletMode.VIEW);
actionResponse.setWindowState(WindowState.NORMAL);
2,FileUploadPortlet.java file
import java.io.*;
import javax.activation.DataHandler;
import javax.mail.MessagingException;
import javax.mail.internet.MimeBodyPart;
import javax.portlet.*;
import oracle.portal.portlet.sample.CustomizablePortlet;
public class FileUploadPortlet extends CustomizablePortlet
private static final String FILE_PARAM = "file";
private static final String SUBMIT_PARAM = "submit";
private static final String DEFAULT_CHARSET = "ISO-8859-1";
private static final String uploadRoot = "";
public FileUploadPortlet()
public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.print("<form action=\"");
out.print(response.createActionURL().toString());
out.println("\" enctype=\"multipart/form-data\" method=\"post\">");
out.println("<center><table border=\"0\">");
out.println("<tr>");
out.print("<td class=\"portlet-form-field\" align=\"right\">");
out.print("Please browse to an HTML file:");
out.println("</td>");
out.print("<td>");
out.print("<input class=\"portlet-form-input-field\" type=\"file\" name=\"");
out.print("file");
out.print("\">");
out.println("</td>");
out.println("</tr>");
out.println("<tr>");
out.println("<td colspan=\"2\" align=\"center\">");
out.print("<input type=\"submit\" class=\"portlet-form-button\" name=\"");
out.print("submit");
out.print("\" value=\"Display\">");
out.println("</td>");
out.println("</tr>");
out.println("</table>");
out.println("</form>");
String lastFile = request.getPreferences().getValue("file", null);
if(lastFile != null) {
out.println("<hr width=\"100%\"><br>");
out.print(lastFile);
public void processAction(ActionRequest request, ActionResponse actionResponse) throws PortletException, IOException {
FormDataParser parsedRequest = new FormDataParser(request);
MimeBodyPart mbp = parsedRequest.getMimeBodyPart("file");
if(mbp == null)
super.processAction(request, actionResponse);
else
try {
String fileName= mbp.getFileName();
int splash = fileName.lastIndexOf("\\");
if(splash != -1)
fileName = fileName.substring(splash +1, fileName.length()).trim();
String contentType = mbp.getContentType();
String charSet = getCharsetFromContentType(contentType);
int sepIndex = contentType.indexOf(';');
if(sepIndex != -1)
contentType = contentType.substring(0, sepIndex).trim();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
mbp.getDataHandler().writeTo(bos);
bos.close();
String content = new String(bos.toByteArray(), charSet);
FileOutputStream fos = new FileOutputStream(fileName);
fos.write(bos.toByteArray());
fos.close();
PortletPreferences prefs = request.getPreferences();
prefs.setValue("file", fileName + "upload ok");
prefs.store();
catch(MessagingException me) {
throw new PortletException(me);
public static String getCharsetFromContentType(String contentType) {
int lastPos;
if((lastPos = contentType.indexOf(';')) == -1)
return "ISO-8859-1";
lastPos++;
String lowerContentType = contentType.toLowerCase();
int nextPos;
do {
nextPos = lowerContentType.indexOf(';', lastPos);
String param;
if(nextPos == -1)
param = lowerContentType.substring(lastPos).trim();
else
param = lowerContentType.substring(lastPos, nextPos).trim();
if(param.startsWith("charset=") && param.length() > 8)
return param.substring(8);
lastPos = nextPos + 1;
} while(nextPos != -1);
return "ISO-8859-1";
3,FormDataParser.java file
import java.io.*;
import java.util.*;
import javax.activation.DataSource;
import javax.mail.MessagingException;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMultipart;
import javax.portlet.ActionRequest;
import javax.portlet.PortletException;
public class FormDataParser {
private static final String MULTIPART_PREFIX = "multipart/";
private static final String MULTIPART_FORM_DATA = "multipart/form-data";
private static final String PLAIN_TEXT = "text/plain";
private ActionRequest mWrappedRequest;
private Map mParams;
private Map mBodyParts;
private boolean mIsInitialized;
private boolean mHasMultipart;
public FormDataParser(ActionRequest request) {
mWrappedRequest = request;
public String getParameter(String name) throws PortletException {
String value = mWrappedRequest.getParameter(name);
if(value != null)
return value;
initParameters();
if(!mHasMultipart)
return null;
List paramList = (List)mParams.get(name);
if(paramList != null)
return (String)paramList.get(0);
else
return null;
public String[] getParameterValues(String name) throws PortletException {
String values[] = mWrappedRequest.getParameterValues(name);
if(!mHasMultipart)
return values;
initParameters();
List valueList = (List)mParams.get(name);
if(valueList == null)
return values;
int size = valueList.size();
if(values != null) {
List newValueList = new ArrayList(values.length + size);
newValueList.addAll(Arrays.asList(values));
newValueList.addAll(valueList);
valueList = newValueList;
values = new String[size];
valueList.toArray(values);
return values;
public MimeBodyPart getMimeBodyPart(String name) throws PortletException {
initParameters();
if(!mHasMultipart) {
return null;
} else {
List parts = (List)mBodyParts.get(name);
return parts != null ? (MimeBodyPart)parts.get(0) : null;
public MimeBodyPart[] getMimeBodyParts(String name) throws PortletException {
initParameters();
if(!mHasMultipart)
return null;
List parts = (List)mBodyParts.get(name);
if(parts == null) {
return null;
} else {
MimeBodyPart mimeBodyParts[] = new MimeBodyPart[parts.size()];
parts.toArray(mimeBodyParts);
return mimeBodyParts;
private void initParameters() throws PortletException {
if(mIsInitialized)
return;
String contentType = mWrappedRequest.getContentType();
if(contentType == null) {
mIsInitialized = true;
return;
int sepIndex = contentType.indexOf(';');
if(sepIndex != -1)
contentType = contentType.substring(0, sepIndex).trim();
if(contentType.equalsIgnoreCase("multipart/form-data")) {
mParams = new HashMap(20);
mBodyParts = new HashMap(20);
DataSource ds = new DataSource() {
public InputStream getInputStream() throws IOException {
return mWrappedRequest.getPortletInputStream();
public OutputStream getOutputStream() throws IOException {
throw new IOException("OutputStream not available");
public String getContentType() {
return mWrappedRequest.getContentType();
public String getName() {
return getClass().getName();
try {
MimeMultipart multipartMessage = new MimeMultipart(ds);
parseMultiPart(multipartMessage, null);
catch(MessagingException me) {
throw new PortletException(me);
catch(IOException ioe) {
throw new PortletException(ioe);
mHasMultipart = true;
mIsInitialized = true;
private void parseMultiPart(MimeMultipart multipartMessage, String parentFieldName) throws MessagingException, IOException {
int partCount = multipartMessage.getCount();
for(int i = 0; i < partCount; i++) {
javax.mail.BodyPart part = multipartMessage.getBodyPart(i);
if(part instanceof MimeBodyPart) {
MimeBodyPart mimePart = (MimeBodyPart)part;
String disps[] = mimePart.getHeader("Content-Disposition");
if(disps != null && disps.length != 0) {
String disp = disps[0];
String lcDisp = disp.toLowerCase();
int nameStart;
int nameEnd;
if((nameStart = lcDisp.indexOf("name=\"")) != -1 && (nameEnd = lcDisp.indexOf("\"", nameStart + 6)) != -1)
parentFieldName = disp.substring(nameStart + 6, nameEnd);
if(parentFieldName != null)
if(mimePart.getContentType().toLowerCase().startsWith("multipart/")) {
Object content = mimePart.getContent();
if(content instanceof MimeMultipart)
parseMultiPart((MimeMultipart)content, parentFieldName);
} else
if((nameStart = lcDisp.indexOf("filename=\"")) != -1 && (nameEnd = lcDisp.indexOf("\"", nameStart + 10)) != -1) {
List values = (List)mBodyParts.get(parentFieldName);
if(values == null) {
values = new ArrayList(1);
mBodyParts.put(parentFieldName, values);
values.add(mimePart);
} else
if(mimePart.getContentType().toLowerCase().startsWith("text/plain")) {
Object content = mimePart.getContent();
if(content instanceof String) {
List values = (List)mParams.get(parentFieldName);
if(values == null) {
values = new ArrayList(1);
mParams.put(parentFieldName, values);
values.add((String)content);
4.web.xml file
<?xml version = '1.0' encoding = 'ISO-8859-1'?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>hanhuiwen OracleSamplePortlets</display-name>
<description>hanhuiwen Oracle Sample Portlet Application</description>
<servlet>
<servlet-name>portletdeploy</servlet-name>
<servlet-class>oracle.webdb.wsrp.server.deploy.PortletDeployServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>portletjaxrpc</servlet-name>
<servlet-class>com.sun.xml.rpc.server.http.JAXRPCServlet</servlet-class>
<init-param>
<param-name>configuration.file</param-name>
<param-value>/WEB-INF/WSRPService_Config.properties</param-value>
</init-param>
</servlet>
<servlet>
<servlet-name>portletresource</servlet-name>
<servlet-class>oracle.webdb.wsrp.server.ResourceServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>ChartServlet</servlet-name>
<display-name>Chart Servlet</display-name>
<description>Demo image-generating servlet</description>
<servlet-class>oracle.portal.portlet.sample.chart.ChartServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>uix</servlet-name>
<servlet-class>oracle.cabo.servlet.UIXServlet</servlet-class>
<init-param>
<param-name>oracle.cabo.servlet.pageBroker</param-name>
<param-value>oracle.cabo.servlet.xml.UIXPageBroker</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>ChartServlet</servlet-name>
<url-pattern>/chart*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>portletjaxrpc</servlet-name>
<url-pattern>/portlets*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>portletresource</servlet-name>
<url-pattern>/portletresource*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>uix</servlet-name>
<url-pattern>*.uix</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>uix</servlet-name>
<url-pattern>/uix/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>60</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.uix</welcome-file>
</welcome-file-list>
<!--
LogLevel controls the amount of information logged. There are 7 log levels:
0 - logging disabled
1 - configuration
2 - severe error
3 - warning
4 - throwing exception
5 - performance
6 - information
7 - debug
The oracle.portal.log.Logger interface defines methods that map to these 7
log levels. However, there are also 2 methods that do not map to log
levels. These methods are included for backwards compatibility and data
logged using these methods will always be logged regardless of the log level.
-->
<env-entry>
<env-entry-name>oracle/portal/log/logLevel</env-entry-name>
<env-entry-type>java.lang.Integer</env-entry-type>
<env-entry-value>7</env-entry-value>
</env-entry>
</web-app>
5.portlet.xml
<?xml version = '1.0' encoding = 'UTF-8'?>
<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd" version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd">
<portlet>
<description xml:lang="en">A portlet that demonstrates the file upload features of the Java Portlet Specification.</description>
<portlet-name>FileUpload</portlet-name>
<portlet-class>FileUploadPortlet</portlet-class>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>help</portlet-mode>
<portlet-mode>about</portlet-mode>
<portlet-mode>edit_defaults</portlet-mode>
</supports>
<supported-locale>en</supported-locale>
<portlet-info>
<title>File Upload Portlet</title>
<short-title>File Upload</short-title>
<keywords>File,Upload, Portlet</keywords>
</portlet-info>
</portlet>
<custom-portlet-mode>
<description xml:lang="en">This mode should be used by the portlet to display information on the portlet's purpose, origin, version, etc.</description>
<portlet-mode>about</portlet-mode>
</custom-portlet-mode>
<custom-portlet-mode>
<description xml:lang="en">This mode signifies that the portlet should render a screen to set the default values for the modifiable preferences that are typically changed in the EDIT screen. Calling this mode requires that the user must have administrator rights.</description>
<portlet-mode>edit_defaults</portlet-mode>
</custom-portlet-mode>
<custom-portlet-mode>
<description xml:lang="en">This mode should be used by the portlet to render output without the need of having back-end connections or user specific data available.</description>
<portlet-mode>preview</portlet-mode>
</custom-portlet-mode>
<user-attribute>
<name>user.name.given</name>
</user-attribute>
<user-attribute>
<name>user.name.family</name>
</user-attribute>
<user-attribute>
<name>user.name.middle</name>
</user-attribute>
<user-attribute>
<name>user.name.nickname</name>
</user-attribute>
<user-attribute>
<name>user.bdate</name>
</user-attribute>
<user-attribute>
<name>user.business-info.online.email</name>
</user-attribute>
</portlet-app>Hello i had exactly the same error, but not with file upload.
I'm sure you have in your application lib directory to jars which aren't compatible to each other.
And the problem occured between my myfaces and tomahawk jars .
See this page:
http://wiki.apache.org/myfaces/CompatibilityMatrix
It tells you which myfaces and tomahawk jars you can use together.
Hope it can help.
bye -
Adobe Muse won't publish (Error uploading file)
After making simple animations using Adobe Edge Animate it seems as though none of the assets will publish with my site after importing them into Muse.
In Edge animate I saved for "web animation" and published. Then I went to muse and hit "place". I went to preview and everything works fine. When I go to publish there are always errors in uploading my assets with '.png' extensions.
Any help is much appreciated. I have completely scrapped my website and created another, reinstalled Animate and have renamed all my files, I'm not sure whats wrong here.
I got one animation working, and that can be seen here under the Photography section, but I have multiples that will be shown on my page at one time.
http://chasebodydesign.businesscatalyst.comI get the error uploading file everytime I try publishing the animation.
-
1. when use com.oreilly.servlet.MultipartRequest to handle the file upload, can I change the upload file name .
2. how com.oreilly.servlet.MultipartReques handle file upload? do it change to byte ?
what different? if I use the following method?
File uploadedFile = (File) mp.getFile("filename");
FileOutputStream fos = new FileOutputStream(filename);
byte[] uploadedFileBuf = new byte[(int) uploadedFile.length()];
fos.write(data);
fos.close();My questions are
1) when use oreilly package to do file upload , it looks like i line of code is enough to store the upload file in the
file direction.
MultipartRequest multi =
new MultipartRequest(request, dirName, 10*1024*1024); // 10MB
why some example still use FileOutputStream?
outs = new FileOutputStream(UPLOADDIR+fileName);
filePart.writeTo(outs);
outs.flush();
outs.close();
2) can I rename the file name when I use oreilly package? -
Request.getParameter() when uploading files
Hi, I need to upload files and do other works .. such that, in my html ..
<form name="composer" method="post" ENCTYPE="multipart/form-data">
<input type=hidden name="a" value="a">
<input type=File name=inputfile>
<inpu type=button name=Upload onClick='upload file'>
<inpu type=button name=otherStuff onClick='do other stuff'>
</form>
In the jsp for 'do other stuff', I have the following statement to get the value of a
String a = request.getParameter("a");
However, it returns 'null', if I erase the 'ENCTYPE' part from the html file, it works. How can I get it right?If your ENCTYPE is multi-part/form-data, then there is another technichque to read the form parameters.
request.getParameter() won't work.
first u need to read the requenct explicitely and divide the contents into parameters, files etc. and then read the parameter values.
you can get a lot of stuff regarding this on web, like 'uploading files using jsp'.
have fun!! -
Remove link for uploaded files in application
Hi all,
I've been following the tutorial on how to upload and download files in application at http://download-uk.oracle.com/docs/cd/B32472_01/doc/appdev.300/b32469/up_dn_files.htm. I have now created my own table which stores the uploaded files and can download them successfully. I would now like to add the ability to delete these files within the application and was wondering what the best way of doing this was?
I would like to add another column to the displayed report with a 'Remove file' link for each listed file, which when clicked would delete the file from the table. I've already tried using a similar method to the one used to upload the files (instead of uploading the file, the called procedure deletes it from the table using the specified ID), but this causes the application to display a blank page when the link is clicked, which I dont want (but does delete the file).
I would appreciate any suggestions.
Regards,
DaveDave,
See the login page:
http://htmldb.oracle.com/pls/otn/f?p=31517:101
There are details on how to access the application builder, where you can see how the
setup of that download, delete, upload application has been done.
Denes Kubicek
http://deneskubicek.blogspot.com/
http://htmldb.oracle.com/pls/otn/f?p=31517:1
------------------------------------------------------------------- -
Delete an uploaded file (in custom table) from a report
Hi,
I have a report of uploaded files (the files are saved in my own table, not in APEX_APPLICATION_FILES) - I'd like to add a delete link to each file in my report so that the user can delete a particular file.
How do I go about doing this?
Thanks.Melissa,
It is now working. You missed couple of things:
1. javascript in the header
2. you were pointing to the page 1 and your process was on the page 2
3. you passed the value to a non existing item on the page 3
4. the request which would fire the delete process was triggered by a wrong request
Denes Kubicek
http://deneskubicek.blogspot.com/
http://www.opal-consulting.de/training
http://htmldb.oracle.com/pls/otn/f?p=31517:1
------------------------------------------------------------------- -
How to upload file from a client machine to server machine
hei evryone!
can anyone pls help me on how i can upload file from a client machine to another machine (or server). using jsp.Then later on, i can also retrieve the names of these files to place it as values for option tag in an html form.I have a seperate screen for uploading the file and the screen for displaying all the files that were uploaded on the server...
any sample code/ ideas would be much appreciated.Thx!!!!hei evryone!
can anyone pls help me on how i can upload file from a client machine to another machine (or server). using jsp.Then later on, i can also retrieve the names of these files to place it as values for option tag in an html form.I have a seperate screen for uploading the file and the screen for displaying all the files that were uploaded on the server...
any sample code/ ideas would be much appreciated.Thx!!!! -
How to upload file from client to server
Can someone please help.
User needs to browse file on his desktop and upload file using browse button. This file should then be uploaded to the server. I am using javascript in the front end and servlet in the back.
Any help will be highly appreciated.
Thanks,
IndrasishJakarta Commons FileUpload is the standard way of doing the file uploading these days. You can find source, binaries and documentation at the Jakarta Site http://jakarta.apache.org/ . The Commons has a number of subprojects, so start with the Commons libraries, then find FileUpload.
Brian -
How to upload file from client to server in servlets.
actually in my application i have to upload file from client m/c to server.
it is not possible through file i/p stream as fileStreams does not work on network. Please mail me if you have any solution to this.
Thank's in advance............Haii roshan
Pls go through this thread..
http://forum.java.sun.com/thread.jspa?forumID=45&threadID=616589
regards
Shanu -
How to upload file from Application Server?
Dear Friends,
How to upload file from Application Server?
Plz. with example...
Regards,
Dharmeshhi,
check the code for upload from application server.
tables: kna1.
types: begin of s_file,
customer type kna1-kunnr,
country type kna1-land1,
name type kna1-name1,
region type kna1-regio,
end of s_file.
*--Internal tables
data: it_file type s_file occurs 0 with header line.
*-- Selection screen
selection-screen: begin of block b1 with frame title text-001.
parameter: p_file type rlgrap-filename default 'C:/customer.txt'
obligatory.
selection-screen: end of block b1.
*-- At selection screen
at selection-screen on value-request for p_file.
perform file_help using p_file.
*-- Process File
start-of-selection.
perform upload_file using p_file.
*-- write File data to o/p
end-of-selection.
perform write_data.
*& Form file_help
form file_help using p_p_file.
data: l_filepath type ibipparms-path.
call function 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ' '
importing
file_name = l_filepath
p_p_file = l_filepath.
endform. " file_help
*& Form upload_file
form upload_file using p_p_file.
call function 'WS_UPLOAD'
exporting
filename = p_p_file
filetype = 'DAT'
IMPORTING
FILELENGTH =
tables
data_tab = it_file
exceptions
conversion_error = 1
file_open_error = 2
file_read_error = 3
invalid_type = 4
no_batch = 5
unknown_error = 6
invalid_table_width = 7
gui_refuse_filetransfer = 8
customer_error = 9
no_authority = 10
others = 11
if sy-subrc <> 0.
message i001.
endif.
endform. " upload_file
*& Form write_data
form write_data .
loop at it_file.
write:/ it_file-customer, it_file-country, it_file-name,
it_file-region.
endloop.
endform.
regards,
keerthi. -
Is there a way to silently upload files?
Ok, so I've taken the plunge. I've started working on an AIR
app using Flash CS3. I'm putting together a little app that will
keep my online store updated with all the product updates from our
wholesaler. This includes parsing a csv file, downloading product
images from the wholesaler, updating the database, and then
uploading the images to our server.
The problem is that AIR does not seem to have the
functionality to silently upload files! Sure, I can use the
file.reference object to fire off the browse method, which then
opens the OS file browser window BUT I would really like the whole
thing to be hands off. In the past, I've written these types of
apps using Visual Studio but I haven't touched VS in two years.
Has anyone run across a way to silently upload or ftp files
in AIR?Hey Oliver,
Thanks for your answer--the fact that it CAN be done has
gotten me a lot further on finding a solution. Here's what I have
so far. As it runs, I can see the progress and completion of the
upload but I'm still not getting it saved. I'm uploading it to a
ColdFusion processing page.
AS3 Code:
import flash.filesystem.*;
import flash.net.URLRequest;
//Silent File Upload (no browse window)
function imageUpload(imageName,uploadPage):void
trace('Starting Upload of ' + imageName + '\n');
var myFile:File =
File.applicationDirectory.resolvePath(imageName);
var request:URLRequest = new URLRequest(uploadPage);
request.method = URLRequestMethod.POST;
myFile.addEventListener(ProgressEvent.PROGRESS,progressHandler);
myFile.addEventListener(Event.COMPLETE,completeHandler);
myFile.upload(request,"theFile");
function progressHandler(event:ProgressEvent):void {
var file:FileReference = FileReference(event.target);
var pLoaded =
Math.ceil(event.bytesLoaded/event.bytesTotal*100);
trace(pLoaded + '% uploaded');
function completeHandler(event:Event):void
trace ('Upload complete.');
var uploadPage = "
http://www.aaronbday.com/upload_file.cfm";
imageUpload("angelic_cat.jpg",uploadPage);
Here's the CFM page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=utf-8" />
<title>Upload File</title>
</head>
<body>
<cfif isDefined("form.theFile")>
<!---we only want images--->
<cffile
action="upload"
destination="#ExpandPath("test/")#"
filefield="theFile"
nameconflict="overwrite"
accept="image/jpg,image/jpeg,image/gif,image/pjpeg"
>
<cfoutput><img src="test/#cffile.serverFile#"
/></cfoutput>
<cfelse>
<form method="post" action="upload_file.cfm"
enctype="multipart/form-data">
<input type="file" name="theFile" />
<input type="submit" name="Submit" />
</form>
</cfif>
</body>
</html>
Any ideas? Thanks! -
Problem while uploading file from application server to internal tab in BG
Hi all,
When i see the file in application server.data is like this
#################00\);_(#####}#-#}###############################00\);_(#####}#-#}###############################00\);_(*#####}#-#}#########
###################}###}#############A#############???#00\);_(*#################;_(@_) ########???# ########???# ########???###
#######???#########}###}#############)##############}##00\);_(*#################;_(@_) ############ ############ ##############
###################}#A#}#############:##############}##00\);_(#################;_(@_) }###}##############################00\);_(*##########
#######???#########}#-#}#############F#################00\);_(#####}###}#############@#################00\);_(#################;_(@_) #####
###################}#-#}#############3#################00\);_(#####}#U#}#############E#################00\);_(#################;_(@_) #####
Because the csv which is uploaded has dropdowns and some formattings.
when download from tcode cg3y i am getting correct file
When try to use open(binary mode) and read dataset i getting data as it is (junk).
i need to process in background.
Any help.
Rhea.upload file to string format
begin of ty_tab,
string type char200,
end of ty_tab.
loop at ty_tab into string
use statement replace string into tab deliminated fromat(particular occurance in string)
now call class to break string at tab into fields
endloop.
DATA : BEGIN OF i_data OCCURS 0,
data(200) TYPE c, "To hold Upload file data
END OF i_data.
OPEN DATASET v_str FOR INPUT
IN TEXT MODE
ENCODING DEFAULT IGNORING CONVERSION ERRORS.
IF sy-subrc EQ 0.
DO.
*Read a line from input file
READ DATASET v_str INTO i_data-data.
IF sy-subrc NE 0.
EXIT.
ENDIF.
*Append record to an internal table
APPEND i_data.
CLEAR: i_data.
ENDDO.
*Close the file
CLOSE DATASET v_str.
*---Start of inserti
LOOP AT i_data.
REPLACE ALL OCCURRENCES OF '"' IN i_data WITH '#'.
SPLIT i_data AT cl_abap_char_utilities=>horizontal_tab
INTO i_doc-pvaudt
i_doc-pvpate
i_doc-vecatc
i_doc-vhvend
i_doc-vhidt8
i_doc-vhinvn
i_doc-vhhexp
i_doc-vhiref.
Maybe you are looking for
-
Trying to discard an app into TRASH and I receive a message that "app cannot be removed because it is locked." How can I unlock an app???
-
After attempting to import latest photos from my iPhone, Places is not updating in iPhoto it just keeps spinning and the photos are not importing plus I cannot quit iPhoto and shut down my Mac. Any suggustions?
-
BPS Flat File Upload Error Messages
Hi, I am using the BPS flat file upload and am getting error messages. These error messages are coming from the user exit in the characteristics relationships. Unfortunately the message does not indicate which line on the upload file the error is for
-
How can I get my music onto my iphone 4S
I hae just purchased an iphone 4s and can't seem to transfer my music from my computer to it. Never had this problem with my old iphone 2. Most of my music is CDs which I have transferred to itunes on my home computer (an imac, still running leopar
-
Argument Error #1063: Argument count mismatch
So I'm having another issue my code. I keep getting this error whenever I test: ArgumentError: Error #1063: Argument count mismatch on Enemy(). Expected 2, got 0. at flash.display::Sprite/constructChildren() at flash.display::Sprite() at