How to upload files(particularly pictures) in JSP & Servlet
Please help me.That is the greatest requirement of my MIT final term.
Thank in advance.
Edited by: Zahid_Ghafoor on Sep 10, 2008 12:40 AM
Thanks Mattias,
This is very good but a little bit complicated uploading.Please send me another.
Similar Messages
-
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. -
How to upload file in a server
Hi,
How to upload file to server through reporting. Plz guide me and what would be the probable code.
ThanksHi,
Try this Report Program.
*& Report ZUPLOADTAB *
*& Example of Uploading tab delimited file *
REPORT zuploadtab .
PARAMETERS: p_infile LIKE rlgrap-filename
OBLIGATORY DEFAULT '/usr/sap/'..
DATA: ld_file LIKE rlgrap-filename.
*Internal tabe to store upload data
TYPES: BEGIN OF t_record,
name1 like pa0002-VORNA,
name2 like pa0002-name2,
age type i,
END OF t_record.
DATA: it_record TYPE STANDARD TABLE OF t_record INITIAL SIZE 0,
wa_record TYPE t_record.
*Text version of data table
TYPES: begin of t_uploadtxt,
name1(10) type c,
name2(15) type c,
age(5) type c,
end of t_uploadtxt.
DATA: wa_uploadtxt TYPE t_uploadtxt.
*String value to data in initially.
DATA: wa_string(255) type c.
constants: con_tab TYPE x VALUE '09'.
*If you have Unicode check active in program attributes then you will
*need to declare constants as follows:
*class cl_abap_char_utilities definition load.
*constants:
con_tab type c value cl_abap_char_utilities=>HORIZONTAL_TAB.
*START-OF-SELECTION
START-OF-SELECTION.
ld_file = p_infile.
OPEN DATASET ld_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE 0.
ELSE.
DO.
CLEAR: wa_string, wa_uploadtxt.
READ DATASET ld_file INTO wa_string.
IF sy-subrc NE 0.
EXIT.
ELSE.
SPLIT wa_string AT con_tab INTO wa_uploadtxt-name1
wa_uploadtxt-name2
wa_uploadtxt-age.
MOVE-CORRESPONDING wa_uploadtxt TO wa_upload.
APPEND wa_upload TO it_record.
ENDIF.
ENDDO.
CLOSE DATASET ld_file.
ENDIF.
*END-OF-SELECTION
END-OF-SELECTION.
*!! Text data is now contained within the internal table IT_RECORD
Display report data for illustration purposes
loop at it_record into wa_record.
write:/ sy-vline,
(10) wa_record-name1, sy-vline,
(10) wa_record-name2, sy-vline,
(10) wa_record-age, sy-vline.
endloop.
Regards,
Padmam. -
How to upload file in webdynpro abap alv
Hello Friends,
how to upload file in webdynpro abap alv
Regards
Narendra
Moderator message: please search for available information, post in correct "Web Dynpro ABAP" forum if still required.
Edited by: Thomas Zloch on Jun 6, 2011 11:55 AMHi Narendra,
You ahve to search before posting. This discussed many times.
You need to use file upload ui element to upload data. and display in alv.
Please go thorugh this..
http://wiki.sdn.sap.com/wiki/display/WDABAP/UploadandDownloadfilesinWebdynproABAP
Re: Upload .xls file in WDABAP
http://forums.sdn.sap.com/click.jspa?searchID=72307893&messageID=5425671
Cheers,
Kris. -
How to upload files to dashboard obiee 11g
hi,
can anyone explain how to upload files to obiee dashboard.
thanks in advance..refer this link .
http://total-bi.com/2011/02/external-files-obiee-dashboard/ -
How to upload file from desktop or C drive and send as attachments
Hello Experts,
Please tell me
How to upload jpg or gif or drawing files from desktop or any drive and store into R/3 by the same time I have to send mail as a attachment.
I heard that FM
SO_NEW_DOCUMENT_ATT_SEND_API1 is only to send as a attachment what ever the data is present in the internal table only.
please help me on that.I m using this code its having attachment but I m not able to open the file. Please help me
I m using gui_upload to upload the file
PROGRAM ZTEST
no standard page heading line-size 255.
DATA: xfile TYPE string.
data : t_IW51 LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: OBJPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.
DATA: OBJHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.
DATA: OBJBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: OBJTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.
DATA: DOC_CHNG LIKE SODOCCHGI1.
DATA: TAB_LINES LIKE SY-TABIX.
data : email type table of BAPIADSMTP.
PARAMETERS : file LIKE rlgrap-filename OBLIGATORY.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR file.
CLEAR file.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
file_name = file.
xfile = file.
START-OF-SELECTION.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = xfile
filetype = 'ASC'
has_field_separator = 'X'
TABLES
data_tab = t_IW51.
Creation of the document to be sent
File Name
DOC_CHNG-OBJ_NAME = 'SENDFILE'.
Mail Subject
DOC_CHNG-OBJ_DESCR = 'Send External Mail'.
Mail Contents
OBJTXT = 'Minimum bid : $250000'.
APPEND OBJTXT.
OBJTXT = 'A representation of the pictures up for auction'.
APPEND OBJTXT.
OBJTXT = 'was included as attachment.'.
APPEND OBJTXT.
DESCRIBE TABLE OBJTXT LINES TAB_LINES.
READ TABLE OBJTXT INDEX TAB_LINES.
DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
Creation of the entry for the compressed document
CLEAR OBJPACK-TRANSF_BIN.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 0.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = TAB_LINES.
OBJPACK-DOC_TYPE = 'RAW'.
APPEND OBJPACK.
Creation of the document attachment
(Assume that the data in OBJBIN is in BMP format)
*OBJBIN = ' \O/ '. APPEND OBJBIN.
*OBJBIN = ' | '. APPEND OBJBIN.
*OBJBIN = ' / \ '. APPEND OBJBIN.
OBJBIN[] = t_IW51[].
DESCRIBE TABLE OBJBIN LINES TAB_LINES.
OBJHEAD = 'PICTURE.PDF'.
APPEND OBJHEAD.
OBJBIN[] = t_IW51[].
Creation of the entry for the compressed attachment
OBJPACK-TRANSF_BIN = 'X'.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 1.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = TAB_LINES.
OBJPACK-DOC_TYPE = 'PDF'.
OBJPACK-OBJ_NAME = 'PICTURE'.
OBJPACK-OBJ_DESCR = 'Representation of object 138'.
OBJPACK-DOC_SIZE = TAB_LINES * 255.
APPEND OBJPACK.
Completing the recipient list
RECLIST-RECEIVER = 'email_id have to enter here'.
RECLIST-REC_TYPE = 'U'.
APPEND RECLIST.
RECLIST-RECEIVER = 'ENTEG01'.
RECLIST-REC_TYPE = 'P'.
APPEND RECLIST.
Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = DOC_CHNG
PUT_IN_OUTBOX = 'X'
commit_work = 'X'
TABLES
PACKING_LIST = OBJPACK
OBJECT_HEADER = OBJHEAD
CONTENTS_BIN = OBJBIN
CONTENTS_TXT = OBJTXT
RECEIVERS = RECLIST
*EXCEPTIONS
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
OPERATION_NO_AUTHORIZATION = 4
*OTHERS = 99.
CASE SY-SUBRC.
WHEN 0.
WRITE: / 'Result of the send process:'.
LOOP AT RECLIST.
WRITE: / RECLIST-RECEIVER(48), ':'.
IF RECLIST-RETRN_CODE = 0.
WRITE 'The document was sent'.
ELSE.
WRITE 'The document could not be sent'.
ENDIF.
ENDLOOP.
WHEN 1.
WRITE: / 'No authorization for sending to the specified number',
'of recipients'.
WHEN 2.
WRITE: / 'Document could not be sent to any recipient'.
WHEN 4.
WRITE: / 'No send authorization'.
WHEN OTHERS.
WRITE: / 'Error occurred while sending'.
ENDCASE. -
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 files residing in a folder on local file system .
Hi, I have a problem when trying to upload files.
I have a folder in my local system and have n files in it. Now if i use the file upload element i need to click n times to upload these files. So i want to achieve programatically to upload all the files in a folder given the folder name to the application. Is this possible or is there any restriction to achieve this through webdynpro.
Also how to know programatically all the names of files and folders in a particular folder during web dynpro session.
Regards,
Vinay.Hi Vinayaka,
Watch these links..
Uploading multiple files using the FileUpload UI element
Files...
Regards,
Karthick K Eswaran
Display files in web browser -
Upload file form problem in JSP portlet !!!
Hi!
I use "OrdHttpUploadFile" class for upload file in JSP portlet to database!
Problem is that this class must use FORM ENCTYPE="multipart/form-data" whis I suppose dont work in portlet!?
Which FORM ENCTYPE should I use in portlet! Or there is some other solution for upload file in JSP portlet!?
Thanks!
KristjanThanks for u r reply Mr.Prasad.
Sorry for the delay for reply.
My scenario is in 2 phases
Phase 1. I am taking input from the front end using jsp and writing the contents in to a file and then downloading that file on to my desktop.(Now let us say this one as file downloading)
Phase 2. Now I had designed a page,which locates the downloaded file by using the following tag.
<td><input type ="file" name ="xmlFileName"></td>
In the downloaded xml file I am having applicationid. I am checking whether the application id already xists in the database (or)not.
If already exists in the database , the end user will get one confirmation msg,saying application already exists in the database.
If the user clicks ok again the request has to go to the servlet.
Now the actual problems are
1. When I locate the file on the desktop let us say c:\desktop\krish and click on submit button, it is locating to the file that is present in the server(this is the case for the first time means before checking the application id in the database).
2. when the end user clicks "ok" on the confirmation box , I am not getting the file name,that has to be submitted to the servlet.
Can u plz help me how to resolve this issue.
regards,
Krish -
How to Upload files in a directory?
Can any one tell me how to upload a file in my root directory using jsp.
any example, links,script
i want to upload only a small text file (how to restrict size)Read this tutorial and implement -
http://www.javazoom.net/jzservlets/uploadbean/uploadbean.html
Its easy and effective. -
How to upload file from one machine (windows) to another (linux)through cre
How to upload a file from windows platform to linux platform.
on both platforms sun app server is running.
from creator is there any methode to open ftp port and uploadhttp://www.google.com/search?q=jdbc+blob
Blob processing varies between databases; see also examples for whatever database you are using, e.g.
http://www.google.com/search?q=jdbc+blob+oracle
If you are storing text data instead of binary data, replace "blob" by "clob" in the searches. -
How to upload file to server physical directory
Dear Sir,
My Software Details:
Oracle9i Release 1
Oracle9iAS 1.0.2.2.2
Solaris 8
I have a web application developed using PL/SQL.
How do i upload a file from user to a server physical directory through Oracle9iAS without storing in database?
I can do this if file is uploaded to a 9ias upload table.
But i'm looking for solution on uploading file straight to the physical server directory.
Please advise.
Thanks.
Regards,
Jap Boon ChurnHi Jap,
You won't be able to do this with modplsql if that is what you are asking. modplsql only uploads file into the database.
With that said, however, you can write your own CGI/Servlet/Perl program that does the uploading of files into the server physical directory. In your program, you will need to handle HTTP POST requests so that you can parse out the file contents and write it out onto the file system.
I am sure there is already some CGI/Servlet/Perl program out there that does this. If you search on Google, you should be able to find some and modify it to your needs. Hope that helps. Thanks.
Eric. -
How to upload file to the R/3 server
Hi Experts,
I need to upload scanned documents to the R/3 server.I am using File upload UI element. can anybody tell me how to upload to a server.And at the same time how to download the uploaded content.
Awaiting for the reply.
Regards,
Ramanan.P
Edited by: Ramanan Panchabakesan on Sep 9, 2008 2:14 PMstoring:
The data of your uploaded document is stored in your context node.
Read this data, turn it into a table with one of the SCMS* functions.
store it in a table, or write it into a file. Whichever you choose.
downloading again:
read all data from your table or file
turn it into an xstring using one of the SMCS* functions
put the xstring in the context node bound to your downloadfile element
The principle is deadsimple. The only thing that really matters is where you want to store the file. And that is more of technical ABAP R/3 question, if not a functional question than a webdynpro for abap one. -
How to upload file using *cl_gui_frontend_services* method
hi
i want to upload an image file using this method
and i want to save it in MIME Repository (/SAP/BC/BSP/SAP/PRASHANT)
DATA:
itab TYPE TABLE OF sflight.
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = 'C:\temp\winter.jpg'
filetype = 'ASC'
has_field_separator = '|'
CHANGING
data_tab = itab
IF sy-subrc = 0.
WRITE:/ 'success'.
ENDIF.
So plz tel me how i set given path to upload file using this method .Hi Prashant,
Go through the [Link|https://forums.sdn.sap.com/click.jspa?searchID=24477690&messageID=6684222].
Hope this is helpful.
Regards,
Abhinav -
How to upload files (.doc./.pdf) to the database?
Hello,
I know this question was raised several times before but the answers don't really make me happy.
I have a table with a BLOB-column for the documents (different mime-types) and a varchar2(100)-column for the mime type.
I edited the form in navigator an told the blob-field to store mime-information in the mime-type-field.
Now, do i have to tell portal the mime-type or does it retrieve it itself?
if i have to tell, how do i do so?
How can i fill in the value for the mime-type-field with javascript, when the fieldname is something like abc.def.ghi?
Javascript then will tell me that document.forms.fieldname is not an object.
Wouldn't it be a good idea to write a howto on this subject (and other subjects too, of course)? I'll do the work if you share your knowledge with me.
And, by the way, can you share your wisdom about retrieving the blobs from tha database for displaying and download, too?
thank you very much,
Ralf SchmittHi Ralf,
see in the design time if you are
1)Interested in only one type of content in the blob column then just mention that mime-type in the
for eg.there will be text field "or type in fixed mime type" where you can mention the default type which you are interested in uploading.
2)If you intent to upload files of diffrent type of mime-types then you will have to associate a column for storing the mime types for that file and for this there will be a text field.
for eg. you will have options for "Select a column to store mime information" which will be having list of all the remaining fields in the LOV , you select which field of the table you wish to make for storing mime-type and do not set any default mime-type in the text "or type in fixed mime type" in this case.
more explaination:
=================
for this case create a table like this :
create table for_blob(id number(4),file_name blob,mime_type_of_file varchar2(400));
when you select file_name field while designing the form you will have following option.
"Select a column to store mime information" ---> select mime_type_of_file
"or type in fixed mime type" ---> delete the content of this text field.
Now when you will actually run the form you have to insert mime-types in the text "mime_type_of_file " for eg
for PDF files: Application/pdf
for msword :Application/msword
for the first case just input the mime-type which you wish to upload.
"or type in fixed mime type" ---> delete the content of this text field say for eg for PDF files:Application/pdf
so that at run time you do not have to input any mime-type info and in this case even the field need not have the column for the mime-type.
hope this help.
rahul
Maybe you are looking for
-
I bought an iPhone5 in the US Apple Store using "guest checkout". Now I must CHANGE Ships TO adress, because I forgot apartment number in adress. if I login with my Apple ID, it says that I don't have permission to open that Order. Any ideias anyone?
-
FDMEE BefImport script for SQL source
Hi Experts , I am new to FDMEE and trying to implment it for our process which should pull the data from one of the SQL view and load into Essbase. I am trying to use the Open Interface table and hence trying to builde BefImport event script with hel
-
Problems with BBC iPlayer Desktop and Adobe Air for Mac
I would be grateful for anyone who can help me with a problem I have on my Laptop running Mac OS X Lion 10.7.3.I am having difficulty running BBC iPlayer Desktop and I suspect it is caused by Adobe Air. Recently I was prompted to update Adobe Air to
-
CR not working for me with VS2010
OK with VS2008 I had no problem.. But with VS2010 I can't get Crystal Reports working at all... I have installed - VS 2010 Sp1 - Full Crystal Reports 2008 Sp3 - CRforVS_13_0_1 - CRforVS_redist_13_0_1 (for 32bit and 64bit) I have tried unistalling ev
-
Hi I deleted my videos from my camera roll in my i phone 6 by doing so I lost the link between the original video and the edited video within Adobe Clip. How would I re-sync my video so i don't loose all my edits I did in Adobe Clip app? Thanks