How to upload file to server?
Hi all,
I am writing a code to upload a zip file to client server. I am using Flash Builder 4.6, Extension Builder 2.1 on a Win 7 machine. My request includes login and password authentication and other params. I am sending the file contents as byte array. But, the return code I get from the server suggests that it does not receive any file. It gets null in the file parameter.
Here is my code,
var request:URLRequest = new URLRequest("http://<url>api/plugin.php/");
request.method = URLRequestMethod.POST;
var fileStream:FileStream = new FileStream();
fileStream.open(PKG_FILE, FileMode.READ);
var byteArr:ByteArray = new ByteArray();
fileStream.readBytes(byteArr, 0, fileStream.bytesAvailable);
request.data = "login=" +
LOGIN +
"&password=" +
MD5.hash(PASSWORD) +
"&pkg=" +
byteArr +
"&pkg_name=" +
PKG_NAME;
var loader:URLLoader = new URLLoader();
// Call OnSuccessfulExportif export completes
loader.addEventListener(Event.COMPLETE, OnSuccessfulExport);
// Call OnUnsuccessfulExportif export failed
loader.addEventListener(IOErrorEvent.IO_ERROR, OnUnsuccessfulExport);
loader.load(request);
======================================================
private function OnSuccessfulExport(event:Event):void
trace(event);
I get a callback on OnSuccessfulExport function, but the value returned from the server in event.target.data is that the server received no file.
Am I missing something here?
storing:
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.
Similar Messages
-
Hi every1,
I have the following problem:
I need to store information in files on server, how can I upload a file to a server into a specified directory??
Tnx in advance,
Mort//the server side
ServerSocket acceptSocket = new ServerSocket(port);
while(true) {
Socket s = acceptSocket.accept();
Connect(s);
} // waits for client socket
void Connect(Socket s) {
in = new ObjectInputStream(s.getInputStream());
} // you can create a file object on the client side and send it through an object stream. You should probably make sure that file objects are synchronized. They most likely are. I've never tried this, but there's no reason why it wouldn't work. Make sure to start the output stream before the input stream or you'll get a hang up.
//the client side
s = new Socket(InetAddress ip,int port);
out = new ObjectOutputStream(s.getOutputStream());
out.writeObject(File file); //write the file object to the output stream -
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 server on specific path ?
Hi ,
Friends i have written code to check on local machine to upload , using apache commons file upload.
its working good.
but when i m giving path for web server it is not uploaded on server, what will be the reason ?
dirName = request.getContextPath()+"/uploads" ;
since i want to upload my all files to my : WebAPP_ROOT/uploads
when i am printing using
request.getContextPath( ) +"/uploads" its showing me correct path, but file is not uploading.
I have another issue but might its not secure , as it is showing real physical path to dir
dirName = application.getRealPath("/");
also tell me how secure this is ? it will take by default ROOT HOME to :
WebAPP_ROOT / build/web instead i want WebAPP_ROOT/uploads
provide me solution for this.I am asking about the following security issue.
String picturefile =application.getRealPath("/" + request.getParameter("file"));
or
String picturefile =getServletContext().getRealPath("/" + request.getParameter("file"));
One important note: whenever you access local resources, be very careful to validate the incoming data. A hacker, or a careless
user, can send bogus data to hack your site. For instance, consider what would happen if the value <code>file=../../../../etc/passwd</code> were entered. The user could in this way read your server's password file. -
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 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 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. -
Can i development program with EDK for uploading file to server?
Can I development program with EDK for uploading file to server?How to avoid same name of files?
Thanks!Hi ,
thanks for the quick response.
but the problem is supppose i have a excel sheet with 16 rows and 13 columns(so data).
i am placing this file contents to appserver USING ABOVE fm.
after that i am reading the file from appserver to create SO(idoc),i need 1row-3column data and 2row-2c data.like that.
in unix we will get row data(after uploading to app server) as #mprn#2345# like this so easy to separate when reading.but in MS NT OS 1row data getting stored in different rows in Appserver.so difficult to read.
so the above mentioned FM is OS dependent or is there any way (any other FM) to get same kind of data in different OS.
PLEASE SUGGEST OTHER WISE I NEED TO CODE BASED ON OS.
REGARDS
SARATH -
How to save file on server folder
hi
i was trying to save file in my specify folder path.
but it cann't save on than location.
if i will not specify path then it directly save file on "c:program files\tomcat5.7\bin\mytextfile.txt"
if i will specify perfect path "c://systemfile//mytextfile.txt"
it saves on that location.
if i will define path as ".//www//systemfile//mytextfile.txt"
"//www//systemfile//mytextfile.txt"
"//systemfile//mytextfile.txt"
".//mytextfile.txt" it cann't save file on locationi know how to upload file .
i need to save file on my web folder " /www/file/ xxxx.txt"
how i will save it .over ther in my program i will specify location "c:/Program file/file/xxxxxx.txt" -
How to get file from server while click on link
Hi,
i created on link and i gave one server path to select file from server but while clickinng on link it no displaying any thing.
following is the Destination url that i gave for the item.
/u08/app/appvis/xxex/inst/xxex_apps/xxrbe/logs/appl/conc/log/
please tell me how to get file from server while click on link.Ok I got your requirement now.
If you are getting file names from view attribute then you should not be adding destination URI property for the link.
Instead you can use OADataBoundValueViewObject API.
Try below code in your controller processRequest method:
I am assuming that you are using classic table.
Also in below example it considers OAMessageStyleText and you can replace it with link item if you want.
OATableBean tableBean =
(OATableBean)webBean.findChildRecursive("<table item id>");
OAMessageStyledTextBean m= (OAMessageStyledTextBean)tableBean.findChildRecursive("<message styled text in table item id>");
OADataBoundValueViewObject tip1 = new OADataBoundValueViewObject(m, "/u08/app/appvis/xxex/inst/xxex_apps/xxrbe/logs/appl/conc/log/"+"<vo attr name which stores file name for each row>");
m.setAttributeValue(oracle.cabo.ui.UIConstants.DESTINATION_ATTR, tip1);
Regards,
Sandeep M. -
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/ -
everything went well until the final step "uploading files to server" -- it's been spinning for an hour, "status" still reads 0%, "pause task" and "cancel task" buttons are grayed out in Activity window. Any ideas?
everything went well until the final step "uploading files to server" -- it's been spinning for an hour, "status" still reads 0%, "pause task" and "cancel task" buttons are grayed out in Activity window. Any ideas?
-
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 name a uploaded file in server
Hi,
I am trying to upload files in to my server. Then save it with a unique name and process it.
The following codes can upload the file but I dont know how to save the file with a unique name and then pick up the unique name and process the file.
I need this because
1# Multiple people will upload files at the same time. Therefore I need some mechanism to mark individual file and process it.
Any help will be very much appreciated. Most importantly please be little collaborative. I am just one week old JSP boy :-).
try {
List fileItemsList = servletFileUpload.parseRequest(request);
DiskFileItemFactory diskFileItemFactory = new DiskFileItemFactory();
diskFileItemFactory.setSizeThreshold(102400); /* the unit is bytes */
File repositoryPath = new File("/temp");
diskFileItemFactory.setRepository(repositoryPath);
/* Iterating through the uploaded file*/
Iterator it = fileItemsList.iterator();
while (it.hasNext()){
FileItem fileItem = (FileItem) it.next();
/* Playing around with the uploaded file */
getName = fileItem.getName(); /*File name provided by the browser*/
fileSize = fileItem.getSize(); /*File size in Bytes*/
File saveTo = new File("/upload_files");
fileItem.write(saveTo);
merit wrote:
Hi,
Thanks. That should work but I was thinking of generating some thing random.
I think what ever i enter into "someUniqueName" then file will always be named as "someUniqueName". What would happen if 2 or more people uploads different file at the same time?Use the name of the original file. If File#exists() returns true, then suffix it with a counter or so.
You can find here an article about a file upload filter which contains under each a basic demonstration example with a servlet which does exactly that using FileUtil#uniqueFile(): [http://balusc.blogspot.com/2007/11/multipartfilter.html].
Maybe you are looking for
-
Can I filter pictures by NOT having a certain keyword?
Hello. I was wondering if there was a way to see all pictures in a folder that does NOT have a certain keyword? For example if I have three pictures tagged with the following keywords: Picture 1: food, horse, glue Picture 2: food, cat, soup Picture 3
-
Security Reports - Scheduling daily retrieval
Hi, I have two questions regarding security reports. I do Not have Planning audit trails activated(client does not want that.) But I Do need a daily report of all the changes that the Hyperion admin does to the roles and provisioning of groups and us
-
Turkish Character Problem Using Database Link
Hi all, I have a link created to a 10g XE database, from a 9i database. The link works fine for everything, but there is a problem with Turkish characters. Consider following query; INSERT INTO xxer_char_deneme_brk@teta -- obviously teta is the link
-
LabVIEW File Permissions Error (8) when trying to delete a .SVN checkout directory
This one has me stumped... Our test platform: Windows XP SP2, LabVIEW 8.2.1, TortoiseSVN client 1.45 Build 10425 We would like to delete our checkout folder and download a clean version from our SVN server using LabVIEW. When we try and delete the fo
-
Can executable VI compiled using Windows version AppBuilder be run on Linux OS
Hi, has anyone tried running executable VI, created in Windows version LV, on Linux or other operating systems. Please share your experience...thx Regards