Uploading a file in Webservice
I have WSDL for a web service which takes a file for Uploading. The file is passed as javax.activation.DataHandler. The WSDl contains following details for it .
<xs:element name="uploadFile">
<xs:complexType>
<xs:sequence>
<xs:element name="dataHandler" type="att:datahandler" xmlns:att="http://www.bea.com/servers/wls90/wsee/attachment"/>
<xs:element name="parentPath" type="xs:string"/>
<xs:element name="fileName" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
When I create JAR for the WSDL so as to cal lthe service it generated the class public interface Datahandler extends org.apache.xmlbeans.XmlObject.
While calling it gives following error.
org.apache.xmlbeans.XmlException: C:\Work\EPM.doc:1:1: error: Illegal XML character: 0x11
org.apache.xmlbeans.impl.piccolo.io.IllegalCharException: Illegal XML character: 0x11
at org.apache.xmlbeans.impl.piccolo.xml.UTF8XMLDecoder.decode(UTF8XMLDecoder.java:196)
at org.apache.xmlbeans.impl.piccolo.xml.XMLStreamReader$FastStreamDecoder.read(XMLStreamReader.java:762)
at org.apache.xmlbeans.impl.piccolo.xml.XMLStreamReader.read(XMLStreamReader.java:162)
at org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.yy_refill(PiccoloLexer.java:3474)
at org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.yylex(PiccoloLexer.java:3958)
at org.apache.xmlbeans.impl.piccolo.xml.Piccolo.yylex(Piccolo.java:1290)
at org.apache.xmlbeans.impl.piccolo.xml.Piccolo.yyparse(Piccolo.java:1400)
at org.apache.xmlbeans.impl.piccolo.xml.Piccolo.parse(Piccolo.java:714)
at org.apache.xmlbeans.impl.store.Locale$SaxLoader.load(Locale.java:3435)
at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:1270)
at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:1257)
at org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(SchemaTypeLoaderBase.java:345)
at org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(SchemaTypeLoaderBase.java:252)
at com.bea.servers.wls90.wsee.attachment.Datahandler$Factory.parse(Ljava.io.File;)Lcom.bea.servers.wls90.wsee.attachment.Datahandler;(Unknown Source)
at uk.gov.fsa.dms.ws.client.TestWsClient.testUpload(TestWsClient.java:45)
at uk.gov.fsa.dms.ws.client.TestWsClient.main(TestWsClient.java:30)
Any ideas ?
Thanks
Ravi
http://search.java.sun.com/search/java/index.jsp?col=ja
aforums&qp=&qt=servlet+file+uploadThats a Master Link!!
Similar Messages
-
Error while uploading WSDL file in Interactive Form Data Connection!
I have created we service to return some data based on user input.
I am trying to link this webservice to Interactive adobe form! and While creating new data connection->uploading WSDL file--> I am receiving error i.e. Invalid File.
Please help me in resolving this issue.
I have created this WSDL file copy/pasting XML code generates from "Open WSDL document for selected binding" link in SOAMANAGER.
Regards,
Naveen.IHello,
This is a Webservice created for the FM : HRXSS_PER_READ_EMERGENCY_AR
Here is the sample of the WSDL file generated, as asked by you.
<?xml version="1.0" encoding="utf-8" ?>
- <wsdl:definitions targetNamespace="urn:sap-com:document:sap:soap:functions:mc-style" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="urn:sap-com:document:sap:soap:functions:mc-style" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:n1="urn:sap-com:document:sap:rfc:functions">
- <wsdl:documentation>
<sidl:sidl xmlns:sidl="http://www.sap.com/2007/03/sidl" />
</wsdl:documentation>
<wsp:UsingPolicy wsdl:required="true" />
- <wsp:Policy wsu:Id="BN_BN_ZHR_READ_EMERGENCY">
<saptrnbnd:OptimizedXMLTransfer uri="http://xml.sap.com/2006/11/esi/esp/binxml" xmlns:saptrnbnd="http://www.sap.com/webas/710/soap/features/transportbinding/" wsp:Optional="true" />
<saptrnbnd:OptimizedXMLTransfer uri="http://www.w3.org/2004/08/soap/features/http-optimization" xmlns:saptrnbnd="http://www.sap.com/webas/710/soap/features/transportbinding/" wsp:Optional="true" />
- <wsp:ExactlyOne xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:sapsp="http://www.sap.com/webas/630/soap/features/security/policy" xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility">
- <wsp:All>
- <sp:TransportBinding>
- <wsp:Policy>
- <sp:TransportToken>
- <wsp:Policy>
<sp:HttpsToken />
</wsp:Policy>
</sp:TransportToken>
- <sp:AlgorithmSuite>
- <wsp:Policy>
<sp:TripleDesRsa15 />
</wsp:Policy>
</sp:AlgorithmSuite>
- <sp:Layout>
- <wsp:Policy>
<sp:Strict />
</wsp:Policy>
</sp:Layout>
</wsp:Policy>
</sp:TransportBinding>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
- <wsp:Policy wsu:Id="IF_IF_ZHR_READ_EMERGENCY">
- <sapsession:Session xmlns:sapsession="http://www.sap.com/webas/630/soap/features/session/">
<sapsession:enableSession>false</sapsession:enableSession>
</sapsession:Session>
<sapcentraladmin:CentralAdministration xmlns:sapcentraladmin="http://www.sap.com/webas/700/soap/features/CentralAdministration/" wsp:Optional="true" />
</wsp:Policy>
- <wsp:Policy wsu:Id="OP_IF_OP_HrxssPerReadEmergencyAr">
<sapcomhnd:enableCommit xmlns:sapcomhnd="http://www.sap.com/NW05/soap/features/commit/">false</sapcomhnd:enableCommit>
<sapblock:enableBlocking xmlns:sapblock="http://www.sap.com/NW05/soap/features/blocking/">true</sapblock:enableBlocking>
<saptrhnw05:required xmlns:saptrhnw05="http://www.sap.com/NW05/soap/features/transaction/">no</saptrhnw05:required>
<saprmnw05:enableWSRM xmlns:saprmnw05="http://www.sap.com/NW05/soap/features/wsrm/">false</saprmnw05:enableWSRM>
</wsp:Policy>
- <wsdl:types>
- <xsd:schema attributeFormDefault="qualified" targetNamespace="urn:sap-com:document:sap:rfc:functions">
- <xsd:simpleType name="char1">
- <xsd:restriction base="xsd:string">
<xsd:maxLength value="1" />
</xsd:restriction>
</xsd:simpleType>
"More simple types
<xsd:pattern value="\d*" />
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
- <xsd:schema attributeFormDefault="qualified" targetNamespace="urn:sap-com:document:sap:soap:functions:mc-style" xmlns:n0="urn:sap-com:document:sap:rfc:functions">
<xsd:import namespace="urn:sap-com:document:sap:rfc:functions" />
- <xsd:complexType name="Bapiret2">
- <xsd:sequence>
"More element names
- <xsd:complexType>
- <xsd:sequence>
<xsd:element name="Messages" type="tns:Bapirettab" />
<xsd:element name="Records" type="tns:HcmtBspPaArR0006Tab" />
<xsd:element name="Records2" type="tns:HcmtBspPaArR0021Tab" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
- <wsdl:message name="HrxssPerReadEmergencyAr">
<wsdl:part name="parameters" element="tns:HrxssPerReadEmergencyAr" />
</wsdl:message>
- <wsdl:message name="HrxssPerReadEmergencyArResponse">
<wsdl:part name="parameter" element="tns:HrxssPerReadEmergencyArResponse" />
</wsdl:message>
- <wsdl:portType name="ZHR_READ_EMERGENCY">
- <wsp:Policy>
<wsp:PolicyReference URI="#IF_IF_ZHR_READ_EMERGENCY" />
</wsp:Policy>
- <wsdl:operation name="HrxssPerReadEmergencyAr">
- <wsp:Policy>
<wsp:PolicyReference URI="#OP_IF_OP_HrxssPerReadEmergencyAr" />
</wsp:Policy>
<wsdl:input message="tns:HrxssPerReadEmergencyAr" />
<wsdl:output message="tns:HrxssPerReadEmergencyArResponse" />
</wsdl:operation>
</wsdl:portType>
- <wsdl:binding name="ZHR_READ_EMERGENCY" type="tns:ZHR_READ_EMERGENCY">
- <wsp:Policy>
<wsp:PolicyReference URI="#BN_BN_ZHR_READ_EMERGENCY" />
</wsp:Policy>
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
- <wsdl:operation name="HrxssPerReadEmergencyAr">
<soap:operation soapAction="" style="document" />
- <wsdl:input>
<soap:body use="literal" />
</wsdl:input>
- <wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:service name="service">
- <wsdl:port name="ZHR_READ_EMERGENCY" binding="tns:ZHR_READ_EMERGENCY">
<soap:address location="http://cieh4-srvr.collabera.com:8000/sap/bc/srt/rfc/sap/zhr_read_emergency/900/zhr_read_emergency/zhr_read_emergency" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Cheers,
Remi -
I am trying to upload a file using PRC, I am using .Net 2.0. Here is my code
IRemoteSession rSession = base.portletContext.GetRemotePortalSession();
IDocumentManager dManager = rSession.GetDocumentManager();
IRemoteDocument rDocument = dManager.CreateRemoteDocument(4079, 217, Server.MapPath("temp.txt"));
rDocument.SetType("http://www.plumtree.com/dtm/mime", "text/plain");
rDocument.SetOverrideName("Trying to upload");
rDocument.SetOverrideDescription("No Description");
int docID = -1;
try
docID = rDocument.Save();
catch (Exception ex)
Response.Write(ex);
Response.Write("<BR><BR>" + docID);
The code always falis with following errorPlumtree.Remote.PRC.PortalException: Exception of type 'Plumtree.Remote.PRC.PortalException' was thrown. ---> System.Web.Services.Protocols.SoapException: java.rmi.RemoteException: Error in function PTDataSource.ImportDocument (vDocumentLocationBagAsXML == '1001text/plainD:\Plumtree\RemotePortlets\FileContainer\temp.txt', lDocumentTypeID == 104, pCard == com.plumtree.server.impl.directory.PTCard@65e83f, bSummarize == false, pProvider == null): Error in function PTDataSource.ImportDocument (vDocumentLocationBagAsXML == text/plain1001D:\Plumtree\RemotePortlets\FileContainer\temp.txt, lDocumentTypeID == 104, pCard == com.plumtree.server.impl.directory.PTCard@65e83f, bSummarize == false, pProvider == null): Error in function SOAPEnvelope.Restore (arrayText == [B@7aa6f0): SOAP fault: faultcode='soapenv:Server.userException' faultstring='java.lang.NullPointerException' at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) at com.plumtree.remote.prc.soap.DirectoryAPIService.submitRemoteDocumentMerge(String sLoginToken, Int32 nDataSourceID, Int32[] nFolderIDs, String sLocation, String sTypeID, String sTypeNameSpace, String sOverrideName, String sOverrideDesc, String sLanguage, Boolean bMergeACLs) at com.plumtree.remote.prc.soap.DirectoryProcedures.SubmitRemoteDocument(String sLoginToken, Int32 nDataSourceID, Int32[] nFolderIDs, String sLocation, String sTypeID, String sTypeNameSpace, String sOverrideName, String sOverrideDesc, String sLanguage, Boolean bMergeACLs) --- End of inner exception stack trace --- at Plumtree.Remote.PRC.DocumentWrapper.Save() at Gov.NSW.CCSU.Portal.FileContainer.FileBrowser.cmdUpload_Click(Object sender, EventArgs e) in D:\MyWorks\CCSU\Portal\ALUI\Portlets\FileContainer\FileContainer\FileBrowser.aspx.cs:line 48
I thought that there might be some problem in getting the file from the client,
so i used my own uploading routines for copying the
file in current App's directory,
even then i get the same error.
Any help is greatly appreciated!!!
Thanks,
Avi
[pre]Hello Dmitry,
Thanks a ton for your patience!
I have already tried step 1, still same error.
I have already tried step 2 and it works using Portal UI
Knowledge Directory-> Going to that specific folder - having ID 4079 -> selecting same file from same network share
Followed Step 3 and the result confirmed that I am using the correct DataSourceID
Here is the small piece of code
<Code>
IRemoteSession rSession = this.portletContext.GetRemotePortalSession();
IObjectManager oManager = rSession.GetObjectManager(ObjectClass.DataSource);
IObjectQuery oQuery = oManager.QueryObjects();
for (int i = 0; i < oQuery.GetRowCount(); i++)
Response.Write(oQuery.GetRow(i).GetName() + "-" + oQuery.GetRow(i).GetID() + "<BR>");
</Code>
Step 4 - We are not using ALI Content Service Windows File. Do you reckon I require this for Upload?
Step 5 – I ran PT Spy, reproduced the problem but couldn’t find any exception(On the portal server).
Let me give you a little insight of our dev environment here. Portal Server along with Remote Apps are installed on ServerX and Studio, Content Upload, Collaboration, Publisher are installed on ServerY. To neglect any permission issue I created the network share on ServerY as the Content Upload Service runs on Server Y.
Running PT Spy on other server (running Content Upload Service) showed few errors but I can not make much sense out of those.
What I can understand is
1. It makes the call to [submitRemoteDocumentMerge] with correct parameters.
<Parameter List>
nDataSourceID = 217
nFolderIDs = (1) { 4079 }
sLocation = \\ccsu-gmt-952.gnet.ccsu.nsw.gov.au\TempShare\temp.txt
sTypeID = text/plain
sTypeNameSpace = http://www.plumtree.com/dtm/mime
sOverrideName = Trying to upload
sOverrideDesc = No Description
sLanguage = (null)
bMergeACLs = false <ptLogMsgEnd>
</Parameter List>
2. But the call fails with following stack trace (copied partially)
<Stack Trace>
com.plumtree.server.impl.webservice.PTWebService SOAP call failed, an internal error occured on the remote server. Attempting to parse the SOAP fault for detailed error info. Web Service='File Upload Web Service', SOAP Action='urn:plumtree-com:DocumentProvider.AttachToDocument', URL='http://ServerY:11910/ptupload/services/DocumentProvider'
</Stack Trace>
3. Next line shows following Stack Trace
<Stack Trace>
com.plumtree.server.impl.soap.SOAPEnvelope Error in function SOAPEnvelope.Restore (arrayText == [B@7bd8a5): SOAP fault: faultcode='soapenv:Server.userException' faultstring='java.lang.NullPointerException'
com.plumtree.server.impl.soap.OpenSoapException: SOAP fault: faultcode='soapenv:Server.userException' faultstring='java.lang.NullPointerException'
</Stack Trace>
4. Then it starts giving the same error again.
5. I thought it might be expecting a value in Language Parameter, so I Passed US-en but still it screams.
I can send you the entire trace file if that helps.
Thanks a lot for helping so far, Plumtree is pretty new to me and I am finding it difficult to get my steps going.
Thanks,
Avi
Edited by asolvent at 03/24/2008 10:05 PM -
Adf11g how to open pdf or html files from webservice
hi all,
adf11g how to open pdf or html files from webservice .Hi,
This is standard functionality, that you can read more about in the OLM User Manual. You can upload the files to an OLM content server or to any other content server that can be accessed with a URL.
Regards Anders Northeved -
Error in uploading a file in server
Hi,
We are working in a application whose technologies are Flex 4.0 and .Net 2010.
We are using .Net WCF Service for interacting with backend from the Flex front end.
In our application, we have requirement to upload a file from the client into a server.
We faced the following issue,
Security violation Issue #2032.
Solution: We have found that there is a sandbox restriction to access other domains, then we have placed the crossdomain.xml, which resolves the issue.
But this solution works only in the IE.
We are still getting the same error (Error #2032: Stream Error.) in other browsers - FireFox, Chrome and Safari.
Please let us know if there are any suggestions or solutions for this issue.
Regards,
GuruSiva,
You must apply modifiable binary type in wdDoInit of controller:
ISimpleType stype =
wdContext
.node<YourNode>()
.getNodeInfo()
.getAttribute("FileResource")
.getModifiableSimpleType();
IWDModifiableBinaryType mtype = (IWDModifiableBinaryType)stype;
/* Optional steps: affects only FileDownload control */
/* mtype.setMimeType( WDWebResourceType.JPG_IMAGE); */
/* mtype.setFileName( "picture.jpg" ); */
Sure, to make above work you must use binary type in context designer.
Valery Silaev
SaM Solutions
http://www.sam-solutions.net -
How to upload a file in application server to an internal table
Hi,
I am asked to upload a file from application server to internal table. Can you please suggest me the ways to do it or the function module which helps to browse the application server file names.
I have done a program. But its giving problem in searching the files from application server. I am pasting my code for ur review. Please tell me which part i have to correct or suggest me some other ways to do it.
*& Report ZUPLOAD1
REPORT ZUPLOAD1.
type-pools: truxs.
parameters: p_upl_ps radiobutton group g1 default 'X', "upload from pres. server
p_path type rlgrap-filename,
p_upl_as radiobutton group g1, "upload from appln server
<b>p_dir LIKE filepath-pathintern DEFAULT 'Y_ABAP',
p_file LIKE filepath-pathintern lower case,</b>
p_test as checkbox.
constants: c_x value 'X',
c_tab type c value cl_abap_char_utilities=>horizontal_tab.
types: ty_data(1000) type c. "structure to hold legacy data
data: i_data type standard table of ty_data. "internal table of ty_data
types: begin of stritab,
land1 type v_t604-land1, "structure of legacy file.
stawn type v_t604-stawn,
bemeh type v_t604-bemeh,
impma type v_t604-impma,
minol type v_t604-minol,
end of stritab.
data: gi_itab type standard table of stritab, "internal table of legacy file
gw_itab type stritab. "work area
data: i_raw type truxs_t_text_data,
v_fullpath type string.
at selection-screen on value-request for p_path.
if p_upl_ps = c_x. "if presentation server is selected
perform get_file.
else. "if application server is selected
perform set_file_path.
perform upload_from_server.
perform split_data.
endif.
form get_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ' '
IMPORTING
FILE_NAME = p_path. "getting the file name of pres server
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
I_FIELD_SEPERATOR =
I_LINE_HEADER = 'X' "converting excel to sap and filling in
I_TAB_RAW_DATA = i_raw "internal table
I_FILENAME = p_path
TABLES
I_TAB_CONVERTED_DATA = gi_itab
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endform.
form set_file_path. "Getting the file path of application server
data: lv_file type p_file.
lv_file = p_file.
CALL FUNCTION 'FILE_GET_NAME_USING_PATH'
EXPORTING
CLIENT = SY-MANDT
LOGICAL_PATH = p_dir
OPERATING_SYSTEM = SY-OPSYS
PARAMETER_1 = ' '
PARAMETER_2 = ' '
PARAMETER_3 = ' '
USE_BUFFER = ' '
FILE_NAME = lv_file
USE_PRESENTATION_SERVER = ' '
ELEMINATE_BLANKS = 'X'
IMPORTING
FILE_NAME_WITH_PATH = v_fullpath
EXCEPTIONS
PATH_NOT_FOUND = 1
MISSING_PARAMETER = 2
OPERATING_SYSTEM_NOT_FOUND = 3
FILE_SYSTEM_NOT_FOUND = 4
OTHERS = 5
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endform.
form upload_from_server.
data: lv_msg type string,
lw_data type ty_data.
open dataset v_fullpath for input message lv_msg in text mode encoding default.
if sy-subrc <> 0.
message lv_msg type 'i'.
stop.
endif.
do.
read dataset v_fullpath into lw_data.
if sy-subrc <> 0.
write:/5 'Error in processign data set'.
exit.
endif.
append lw_data to i_data.
enddo.
close dataset v_fullpath.
if sy-subrc <> 0.
write: /5 'Error closing dataset'.
endif.
endform.
form split_data.
data: lw_data type ty_data.
data: lw_itab type stritab.
data: begin of ty_itab,
land1 type v_t604-land1,
stawn type v_t604-stawn,
bemeh type v_t604-bemeh,
impma type v_t604-impma,
minol type v_t604-minol,
end of ty_itab.
loop at i_data into lw_data.
split lw_data at c_tab into
ty_itab-land1
ty_itab-stawn
ty_itab-bemeh
ty_itab-impma
ty_itab-minol.
lw_itab-land1 = ty_itab-land1.
lw_itab-stawn = ty_itab-stawn.
lw_itab-bemeh = ty_itab-bemeh.
lw_itab-impma = ty_itab-impma.
lw_itab-minol = ty_itab-minol.
append lw_itab to gi_itab.
endloop.
endform.
start-of-selection.
loop at gi_itab into gw_itab.
write: /5 'COUNTRY', 'IMPORT CODE', 'SUP UNIT', 'FIRST UOM', 'SECOND UOM',
/5 gw_itab-land1, gw_itab-stawn,gw_itab-bemeh,gw_itab-impma,gw_itab-minol.
endloop.
end-of-selection.
I hope problem must be in p_dir and p_file which are in bold.. Kindly help me out. Thanks in advance.see the following ex:
*& Form SUB_GET_FILEPATH
text
--> p1 text
<-- p2 text
FORM SUB_GET_FILEPATH .
GFILE = 'D:\SAP_INT\INBOUND\INBOX'. "Path
ENDFORM. " SUB_GET_FILEPATH
*& Form SUB_GET_FILE
text
--> p1 text
<-- p2 text
FORM SUB_GET_FILE .
DATA: P_FDIR(200) TYPE C.
DATA: IT_FILEDIR1 TYPE STANDARD TABLE OF TY_FILEDIR WITH HEADER LINE.
P_FDIR = GFILE.
CALL FUNCTION 'RZL_READ_DIR_LOCAL'
EXPORTING
NAME = P_FDIR
TABLES
FILE_TBL = IT_FILEDIR.
REFRESH : IT_FILEDIR1.
LOOP AT IT_FILEDIR.
IF IT_FILEDIR-NAME(4) = 'ZINC' OR IT_FILEDIR-NAME(4) = 'zinc'.
MOVE IT_FILEDIR-NAME TO IT_FILEDIR1-NAME.
APPEND IT_FILEDIR1.
ENDIF.
ENDLOOP.
IF IT_FILEDIR1[] IS INITIAL.
STOP.
ENDIF.
LOOP AT IT_FILEDIR1.
REFRESH: I_TAB.
CLEAR: I_TAB.
NAME = IT_FILEDIR1-NAME.
CONCATENATE: GFILE '\' NAME INTO G_FILE.
OPEN DATASET G_FILE FOR INPUT IN TEXT MODE
ENCODING DEFAULT
IGNORING CONVERSION ERRORS.
IF SY-SUBRC EQ 0.
CONCATENATE 'FILENAME : ' G_FILE INTO I_MSG1.
APPEND I_MSG1.
DO.
READ DATASET G_FILE INTO RECORD.
IF SY-SUBRC = 0.
SPLIT RECORD AT ',' INTO I_TAB-BUKRS I_TAB-EBELN
I_TAB-BLDAT I_TAB-XBLNR I_TAB-LIFNR I_TAB-AMOUNT
I_TAB-CURR I_TAB-BUSAREA
I_TAB-BKTXT I_TAB-DMBTR I_TAB-MENGE I_TAB-SRNO.
MOVE-CORRESPONDING I_TAB TO I_TAB1.
ELSE.
EXIT.
ENDIF.
APPEND I_TAB1.
CLEAR: I_TAB, I_TAB1.
ENDDO.
ENDIF.
CLOSE DATASET G_FILE. -
Hi Experts,
I have created the logical path and filename in FILE tcode.I am trying to upload the pdf file to application server by using this path.But
I am getting message like "Unable to open the file".Even I cannot find the this path in AL11 tcode.Kindly anyone advise how to upload pdf file using
custom path and file created from FILE tcode.
Thanks & Regards,
Anusha.Hi Anusha,
Please give as below.
I forget to say you cannot open the PDF in AL11 and for that you need some configuration, i think it can be done using content server,not sure completely please wait for some more suggestions.
Regards,
Pavan -
Error while uploading the file from Allpcation server in LSMW-7th step
Hi Experts,
what should be the specific CODE PAGE should be maintained while uploading the file from application server in LSMW-7th Step
Thanks in advance,
KSRHi
I mean that there is any seperate CODE PAGE which comes at the bottom of screen while uploading the file from the application server in 7th step.
Is there any specific CODE PAGE to be maintained...
Thanks in advance
Oarsk -
Unable to upload video files via iframe in safari version 3.0
I m not able 2 upload video files via iframe in safari 3.0.
i m facing this issue when i try 2 upload a video file via an iframe.
file gets uploaded properly if i m not using iframe to upload the same.
this issue is seen only in safari version 3.0 and not in the newer version i.e (3.2.1)
do anyone has the asnwer for this problem.....???
would be thankful to him/her...Are you using a BT Home Hub with the IP Phone attached. This holds onto the SIP port that iChat uses. There is no way to get the router to release this port.
I had to return it all to BT as unfit for purpose and switched to Eclipse! -
Upload multiple files WITH correct pairs of form fields into Database
In my form page, I would like to allow 3 files upload and 3 corresponding text fields, so that the filename and text description can be saved in database table in correct pair. Like this:
INSERT INTO table1 (filename,desc) VALUES('photo1.jpg','happy day');
INSERT INTO table1 (filename,desc) VALUES('photo2.jpg','fire camp');
INSERT INTO table1 (filename,desc) VALUES('photo3.jpg','christmas night');
However, using the commons fileupload, http://commons.apache.org/fileupload/, I don't know how to reconstruct my codes so that I can acheieve this result.
if(item.isFormField()){
}else{
}I seems to be restricted from this structure.
The jsp form page
<input type="text" name="description1" value="" />
<input type="file" name="sourcefile" value="" />
<input type="text" name="description2" value="" />
<input type="file" name="sourcefile" value="" />The Servlet file
package Upload;
import sql.*;
import user.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.Map;
import java.util.HashMap;
import java.util.Date;
import java.util.List;
import java.util.Iterator;
import java.io.File;
import java.io.PrintWriter;
import java.io.IOException;
import java.text.SimpleDateFormat;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.*;
public class UploadFile extends HttpServlet {
private String fs;
private String category = null;
private String realpath = null;
public String imagepath = null;
public PrintWriter out;
private Map<String, String> formfield = new HashMap<String, String>();
//Initialize global variables
public void init(ServletConfig config, ServletContext context) throws ServletException {
super.init(config);
//Process the HTTP Post request
public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
response.setContentType("text/html");
PrintWriter out = response.getWriter();
Thumbnail thumb = new Thumbnail();
fs = System.getProperty("file.separator");
this.SetImagePath();
boolean isMultipart = ServletFileUpload.isMultipartContent(request);
if(!isMultipart){
out.print("not multiple part.");
}else{
FileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
List items = null;
try{
items = upload.parseRequest(request);
} catch (FileUploadException e) {
e.printStackTrace();
Iterator itr = items.iterator();
while (itr.hasNext()) {
FileItem item = (FileItem) itr.next();
if(item.isFormField()){
String formvalue = new String(item.getString().getBytes("ISO-8859-1"), "utf-8");
formfield.put(item.getFieldName(),formvalue);
out.println("Normal Form Field, ParaName:" + item.getFieldName() + ", ParaValue: " + formvalue + "<br/>");
}else{
String itemName = item.getName();
String filename = GetTodayDate() + "-" + itemName;
try{
new File(this.imagepath + formfield.get("category")).mkdirs();
new File(this.imagepath + formfield.get("category")+fs+"thumbnails").mkdirs();
//Save the file to the destination path
File savedFile = new File(this.imagepath + formfield.get("category") + fs + filename);
item.write(savedFile);
thumb.Process(this.imagepath + formfield.get("category") +fs+ filename,this.imagepath + formfield.get("category") +fs+ "thumbnails" +fs+ filename, 25, 100);
DBConnection db = new DBConnection();
String sql = "SELECT id from category where name = '"+formfield.get("category")+"'";
db.SelectQuery(sql);
while(db.rs.next()){
int cat_id = db.rs.getInt("id");
sql = "INSERT INTO file (cat_id,filename,description) VALUES ("+cat_id+",'"+filename+"','"+formfield.get("description")+"')";
out.println(sql);
db.RunQuery(sql);
} catch (Exception e){
e.printStackTrace();
HttpSession session = request.getSession();
UserData k = (UserData)session.getAttribute("userdata");
k.setMessage("File Upload successfully");
response.sendRedirect("./Upload.jsp");
//Get today date, it is a test, actually the current date can be retrieved from SQL
public String GetTodayDate(){
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
String today = format.format(new Date());
return today;
//Set the current RealPath which the file calls for this file
public void SetRealPath(){
this.realpath = getServletConfig().getServletContext().getRealPath("/");
public void SetImagePath(){
this.SetRealPath();
this.imagepath = this.realpath + "images" +fs;
}Can anyone give me some code suggestion? Thx.When one hits the submit button - I then get a 404 page error.What is the apaches(?) error log saying? Mostly you get very useful information when looking into the error log!
In any case you may look at how you are Uploading Multiple Files with mod_plsql. -
Trying to get lighttpd to upload a file through perl cgi
Hi, I'm quite new in these things, so I might be doing something obvious wrong, but I'd like some help on this.
I'm trying to make a webpage where people can upload files, this is the html page (located at /srv/html/index.html):
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>lighttpd Test Page</title>
</head>
<body>
<div style="text-align:center; font: 12px sans-serif;">
<span style="font-weight: bold; font-size: 20px;">
Arch Linux
</span>
<br><br>
This is a test page for the lighttpd Web Server.<br>
<form action="/cgi-bin/upload.pl" method="post" enctype="multipart/form-data">
<input type="file" name="fileName" size="40">
<input type="submit" value="Send">
<input type="reset">
</form>
</div>
</body>
</html>
And the backend (in /srv/html/cgi-bin/upload.pl):
#!/usr/bin/perl -wT
use strict;
use CGI;
use CGI::Carp qw ( fatalsToBrowser );
use File::Basename;
$CGI::POST_MAX = 1024 * 1024 * 5000; # 5GB filesize limit
my $safe_filename_characters = "a-zA-Z0-9_.-";
my $upload_dir = "/srv/jail/";
my $query = new CGI;
my $filename = $query->param("fileName");
if ( !$filename )
print $query->header ( );
print "There was a problem uploading your file (filesize limit may be exceeded).";
exit;
my ( $name, $path, $extension ) = fileparse ( $filename, '\..*' );
$filename = $name . $extension;
$filename =~ tr/ /_/;
$filename =~ s/[^$safe_filename_characters]//g;
if ( $filename =~ /^([$safe_filename_characters]+)$/ )
$filename = $1;
else
die "Filename contains invalid characters";
my $upload_filehandle = $query->upload("fileName");
open ( UPLOADFILE, ">$upload_dir/$filename" ) or die "$!";
binmode UPLOADFILE;
while ( <$upload_filehandle> )
print UPLOADFILE;
close UPLOADFILE;
print $query->header ( );
print <<END_HTML;
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Done!</title>
</head>
<body>
<p>Uploading done!</p>
</body>
</html>
END_HTML
My server config:
# lighttpd configuration file
# use it as a base for lighttpd 1.0.0 and above
# $Id: lighttpd.conf,v 1.7 2004/11/03 22:26:05 weigon Exp $
############ Options you really have to take care of ####################
## modules to load
# at least mod_access and mod_accesslog should be loaded
# all other module should only be loaded if really neccesary
# - saves some time
# - saves memory
server.modules = (
# "mod_rewrite",
# "mod_redirect",
# "mod_alias",
"mod_access",
# "mod_cml",
# "mod_trigger_b4_dl",
# "mod_auth",
# "mod_status",
# "mod_setenv",
# "mod_fastcgi",
# "mod_proxy",
# "mod_simple_vhost",
# "mod_evhost",
# "mod_userdir",
"mod_cgi",
# "mod_compress",
# "mod_ssi",
# "mod_usertrack",
# "mod_expire",
# "mod_secdownload",
# "mod_rrdtool",
"mod_accesslog" )
## a static document-root, for virtual-hosting take look at the
## server.virtual-* options
server.document-root = "/srv/http/"
## where to send error-messages to
server.errorlog = "/var/log/lighttpd/error.log"
# files to check for if .../ is requested
index-file.names = ( "index.php", "index.html",
"index.htm", "default.htm" )
## set the event-handler (read the performance section in the manual)
# server.event-handler = "freebsd-kqueue" # needed on OS X
# mimetype mapping
mimetype.assign = (
".pdf" => "application/pdf",
".sig" => "application/pgp-signature",
".spl" => "application/futuresplash",
".class" => "application/octet-stream",
".ps" => "application/postscript",
".torrent" => "application/x-bittorrent",
".dvi" => "application/x-dvi",
".gz" => "application/x-gzip",
".pac" => "application/x-ns-proxy-autoconfig",
".swf" => "application/x-shockwave-flash",
".tar.gz" => "application/x-tgz",
".tgz" => "application/x-tgz",
".tar" => "application/x-tar",
".zip" => "application/zip",
".mp3" => "audio/mpeg",
".m3u" => "audio/x-mpegurl",
".wma" => "audio/x-ms-wma",
".wax" => "audio/x-ms-wax",
".ogg" => "application/ogg",
".wav" => "audio/x-wav",
".gif" => "image/gif",
".jar" => "application/x-java-archive",
".jpg" => "image/jpeg",
".jpeg" => "image/jpeg",
".png" => "image/png",
".xbm" => "image/x-xbitmap",
".xpm" => "image/x-xpixmap",
".xwd" => "image/x-xwindowdump",
".css" => "text/css",
".html" => "text/html",
".htm" => "text/html",
".js" => "text/javascript",
".asc" => "text/plain",
".c" => "text/plain",
".cpp" => "text/plain",
".log" => "text/plain",
".conf" => "text/plain",
".text" => "text/plain",
".txt" => "text/plain",
".dtd" => "text/xml",
".xml" => "text/xml",
".mpeg" => "video/mpeg",
".mpg" => "video/mpeg",
".mov" => "video/quicktime",
".qt" => "video/quicktime",
".avi" => "video/x-msvideo",
".asf" => "video/x-ms-asf",
".asx" => "video/x-ms-asf",
".wmv" => "video/x-ms-wmv",
".bz2" => "application/x-bzip",
".tbz" => "application/x-bzip-compressed-tar",
".tar.bz2" => "application/x-bzip-compressed-tar",
# default mime type
"" => "application/octet-stream",
# Use the "Content-Type" extended attribute to obtain mime type if possible
#mimetype.use-xattr = "enable"
## send a different Server: header
## be nice and keep it at lighttpd
# server.tag = "lighttpd"
#### accesslog module
accesslog.filename = "/var/log/lighttpd/access.log"
## deny access the file-extensions
# ~ is for backupfiles from vi, emacs, joe, ...
# .inc is often used for code includes which should in general not be part
# of the document-root
url.access-deny = ( "~", ".inc" )
$HTTP["url"] =~ "\.pdf$" {
server.range-requests = "disable"
# which extensions should not be handle via static-file transfer
# .php, .pl, .fcgi are most often handled by mod_fastcgi or mod_cgi
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )
######### Options that are good to be but not neccesary to be changed #######
## bind to port (default: 80)
server.port = ###
## bind to localhost (default: all interfaces)
#server.bind = "127.0.0.1"
## error-handler for status 404
#server.error-handler-404 = "/error-handler.html"
#server.error-handler-404 = "/error-handler.php"
## to help the rc.scripts
server.pid-file = "/var/run/lighttpd/lighttpd.pid"
###### virtual hosts
## If you want name-based virtual hosting add the next three settings and load
## mod_simple_vhost
## document-root =
## virtual-server-root + virtual-server-default-host + virtual-server-docroot
## or
## virtual-server-root + http-host + virtual-server-docroot
#simple-vhost.server-root = "/srv/http/vhosts/"
#simple-vhost.default-host = "www.example.org"
#simple-vhost.document-root = "/htdocs/"
## Format: <errorfile-prefix><status-code>.html
## -> ..../status-404.html for 'File not found'
#server.errorfile-prefix = "/usr/share/lighttpd/errors/status-"
#server.errorfile-prefix = "/srv/http/errors/status-"
## virtual directory listings
#dir-listing.activate = "enable"
## enable debugging
#debug.log-request-header = "enable"
#debug.log-response-header = "enable"
#debug.log-request-handling = "enable"
#debug.log-file-not-found = "enable"
### only root can use these options
# chroot() to directory (default: no chroot() )
#server.chroot = "/"
## change uid to <uid> (default: don't care)
server.username = "http"
## change uid to <uid> (default: don't care)
server.groupname = "http"
#### compress module
#compress.cache-dir = "/var/cache/lighttpd/compress/"
#compress.filetype = ("text/plain", "text/html")
#### proxy module
## read proxy.txt for more info
#proxy.server = ( ".php" =>
# ( "localhost" =>
# "host" => "192.168.0.101",
# "port" => 80
#### fastcgi module
## read fastcgi.txt for more info
## for PHP don't forget to set cgi.fix_pathinfo = 1 in the php.ini
#fastcgi.server = ( ".php" =>
# ( "localhost" =>
# "socket" => "/var/run/lighttpd/php-fastcgi.socket",
# "bin-path" => "/usr/bin/php-cgi"
#### CGI module
cgi.assign = ( ".pl" => "/usr/bin/perl",
".cgi" => "/usr/bin/perl" )
#### SSL engine
#$SERVER["socket"] == "0.0.0.0:443" {
ssl.engine = "enable"
ssl.pemfile = "/etc/ssl/private/lighttpd.pem"
# server.errorlog = "/var/log/lighttpd/error-ssl.log"
# accesslog.filename = "/var/log/lighttpd/access-ssl.log"
# server.document-root = "/home/lighttpd/html-ssl"
#### status module
#status.status-url = "/server-status"
#status.config-url = "/server-config"
#### auth module
## read authentication.txt for more info
#auth.backend = "plain"
#auth.backend.plain.userfile = "lighttpd.user"
#auth.backend.plain.groupfile = "lighttpd.group"
#auth.backend.ldap.hostname = "localhost"
#auth.backend.ldap.base-dn = "dc=my-domain,dc=com"
#auth.backend.ldap.filter = "(uid=$)"
#auth.require = ( "/server-status" =>
# "method" => "digest",
# "realm" => "download archiv",
# "require" => "user=jan"
# "/server-config" =>
# "method" => "digest",
# "realm" => "download archiv",
# "require" => "valid-user"
#### url handling modules (rewrite, redirect, access)
#url.rewrite = ( "^/$" => "/server-status" )
#url.redirect = ( "^/wishlist/(.+)" => "http://www.123.org/$1" )
#### both rewrite/redirect support back reference to regex conditional using %n
#$HTTP["host"] =~ "^www\.(.*)" {
# url.redirect = ( "^/(.*)" => "http://%1/$1" )
# define a pattern for the host url finding
# %% => % sign
# %0 => domain name + tld
# %1 => tld
# %2 => domain name without tld
# %3 => subdomain 1 name
# %4 => subdomain 2 name
#evhost.path-pattern = "/srv/http/vhosts/%3/htdocs/"
#### expire module
#expire.url = ( "/buggy/" => "access 2 hours", "/asdhas/" => "access plus 1 seconds 2 minutes")
#### ssi
#ssi.extension = ( ".shtml" )
#### rrdtool
#rrdtool.binary = "/usr/bin/rrdtool"
#rrdtool.db-name = "/var/lib/lighttpd/lighttpd.rrd"
#### setenv
#setenv.add-request-header = ( "TRAV_ENV" => "mysql://user@host/db" )
#setenv.add-response-header = ( "X-Secret-Message" => "42" )
## for mod_trigger_b4_dl
# trigger-before-download.gdbm-filename = "/var/lib/lighttpd/trigger.db"
# trigger-before-download.memcache-hosts = ( "127.0.0.1:11211" )
# trigger-before-download.trigger-url = "^/trigger/"
# trigger-before-download.download-url = "^/download/"
# trigger-before-download.deny-url = "http://127.0.0.1/index.html"
# trigger-before-download.trigger-timeout = 10
## for mod_cml
## don't forget to add index.cml to server.indexfiles
# cml.extension = ".cml"
# cml.memcache-hosts = ( "127.0.0.1:11211" )
#### variable usage:
## variable name without "." is auto prefixed by "var." and becomes "var.bar"
#bar = 1
#var.mystring = "foo"
## integer add
#bar += 1
## string concat, with integer cast as string, result: "www.foo1.com"
#server.name = "www." + mystring + var.bar + ".com"
## array merge
#index-file.names = (foo + ".php") + index-file.names
#index-file.names += (foo + ".php")
#### include
#include /etc/lighttpd/lighttpd-inc.conf
## same as above if you run: "lighttpd -f /etc/lighttpd/lighttpd.conf"
#include "lighttpd-inc.conf"
#### include_shell
#include_shell "echo var.a=1"
## the above is same as:
#var.a=1
The site is running over https with a self signed ssl-cert, if that matters. If I try to upload a file, the browser just quickly reloades the page, the filename still in the input field. The file isn't uploaded and the page that the script should display when completed doesn't show neither.
Does anyone know how to troubleshoot this? I'm not getting any errors, it just doesn't work..I haven't used Websphere before so I can't say much about that. Try putting <%@ page language="Java" %> at the top of your jsp page.
Try putting your java files into a package and see if that helps. I read somewhere that Tomcat once had issues with running classes that weren't in a package. Make sure to put the package statement at the top of your Java files if you do.
Websphere says it caught an unhandled exception. Instead of having your method throw and Exception put your code in a try-catch block and then print a stack trace to see if it says anything when it trys to read and write data.
Try{
PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter("doUpload.txt")));
ServletInputStream in = request.getInputStream();
int a=0;
a=in.read();
while (a!= -1){
pw.print((char) a);
a=in.read();
pw.close();
}catch(Exception e){
e.printStackTrace();
}Sorry I can't really give you more help.
-S- -
Hi
I have an uploading problem to the server. The problem is when I try to upload a file it goes through the correct proceedure,
but does not change the remote file i.e.Index.htm, or three stages1.htm.
My Localroot folder is C:\Gods Plan Web\
The site map layout is C:\Gods Plan Web\Index.htm
The folder for the remote site is /public_html/
Should the local root folder mirror the remote site, i.e./public_html/
if this is so, what should I put into the
(a) Local Root Folder box?
(b) site map layout box?
The FTP is performing well other than changing the intended file.You should be uploading only the contents of your local root to the public_html folder (remote root).
The index.html you use as your site's home page needs to be in your site root. If you look at your Files window in DW, you should have something like the following...
Site - Whatever you named your site
index.html
images
pages
page1.html
page2.html
If you have any folder between Site - and the index.html page, like...
Site - Whatever you named your site
mywebsite
index.html
It will upload to the public_html while still in that folder, so to find your page online, you would need to type something like...
www.mydomain.com/mywebsite
public_html should NOT appear within your local files and if it existed there, would cause a redundancy if uploaded. You would need to type www.yourdomain.com/public_html to see the uploaded pages.
If you could post a screen shot of your expanded Files window while connected to the server (just connect and click the Expand button in Files, don't drill down into any of the directories), we may be able to see the issue. -
Uploading multiple files into wwv_flow_files.
Hi,
I've been happily using the apex file browse button functionality to upload files into the wwv_flow_files table and moving them over to my app specific tables for some time now.
I was wondering; Is there a straight forward way of uploading all the files in a specified folder into the wwv_flow_files table in a single process; Rather than having to upload them one at a time?
Cheers,
Yog.Ok. I've tried creating a new DAD by following the instructions here:
http://www.oracle-base.com/articles/10g/FileUploadDownloadProcedures10g.php
I've tried various combinations but my lack of experience is letting me down I think.
I may not even be on the right tack.
I'm trying to upload a file to a databse table through some kind of automated process. i.e. bypassing the need for a filebrowse button. Ideally I'd like to be able to pass in a filepath to a procedure and for the file to be uploaded.
Can anyone help with this???
Getting desperate.
Yog -
How to upload Excel file in BI using function module in abap program
How to upload Excel file in BI using function module in abap program?
Hi Anuj,
To upload the file , you can try a standard program "RSEPSFTP" .
while you execute the program , a selection screen appears in which the inputs should be give as
RFC destination - The target server name
FTP command- PUT
local file - your file name
local directory - path of your local file
remote file - your target file name
remote directory - where it has to be stored
Hope this is useful for you
Thanks & regards
Anju -
Upload Excel File to SharePoint using VBA
Hi,
I copied and modified the code from a friend which he got it from this website forum.
This apprantely works for some people and not me. Please tell me what I am doing wrong.
Ignore xxxxxx part of the Sharepoint site. Nothing wrong with the site, i tried many combinations, but I get not response, not even an error.
Public Const HR_URL = "http://sun.xxxxxx.com/eng/st/Lists/Database%20Change% 20Request"
Sub test()
'Upload new Excel sheet to SharePoint
Call copyToSharePoint(HR_URL, ThisWorkbook.FullName)
End Sub
'''''''code block from Forum
Public Sub copyToSharePoint(sharepointURL As String, filePath As String)
'On Error GoTo errhandler
'sharePointUrl should not end in a "/"
'Initialize Variables
Dim LlFileLength As Long
Dim Lvarbin() As Byte
Dim LobjXML As Object
Dim LvarBinData As Variant
Dim LstrFileName As String, PstrFullfileName As String, PstrTargetURL As String
Dim fileName As String, lenFileName As Long
'Extract file name
lenFileName = Len(filePath) - InStrRev(filePath, "\")
fileName = Right(filePath, lenFileName)
'Check that the webUrl ends in an "/"
If Right(sharepointURL, 1) <> "/" Then
sharepointURL = sharepointURL & "/"
End If
'**************************** Upload binary files *****************
Set LobjXML = CreateObject("Microsoft.XMLHTTP")
PstrFullfileName = filePath
LlFileLength = FileLen(PstrFullfileName) - 1
' Read the file into a byte array.
ReDim Lvarbin(LlFileLength)
Open PstrFullfileName For Binary As #1
Get #1, , Lvarbin
Close #1
' Convert to variant to PUT.
LvarBinData = Lvarbin
PstrTargetURL = sharepointURL & fileName
' Put the data to the server; false means synchronous.
LobjXML.Open "PUT", PstrTargetURL, False
' Send the file in.
LobjXML.Send LvarBinData
Set LobjXML = Nothing
Exit Sub
errhandler:
If Err.Number = 53 Then
MsgBox "Excel was unable to create the HR file to submit to SharePoint. " & vbNewLine & _
"Please check that you are not running out of disk space and that no MS Office add-in is causing issues with Excel.", vbCritical, "File Error"
Exit Sub
Else
MsgBox "Your HR could not be submitted to SharePoint. The following error occurred:" & vbNewLine & _
"Error " & Err.Number & ": " & Err.Description, vbCritical, "Error Uploading to SharePoint"
Exit Sub
End If
End SubI have made the following code work successfully on a Windows 8 machine with the VBA executing from an Excel 2010 file and the file you want to upload going to a SharePoint 2010 site. If you don't need to use SP content types then simply
take that out of the code. Also, pay attention to the FieldInformation as the Field Display names and Field Internal names can sometimes be different. Cheers.
Public Sub copyDocToSP()
Const strLocalFile = "C:\temp\myLocalFile.pdf"
Const spBASE_URL = "https://thesharepointdomian/sites/yoursite/"
Const spDOC_LIB = "Your SP Doc Library Name"
Const spFILE_NAME = "FileNameOnceOnSharepoint.pdf"
Const spCONTENT_TYPE = "0x000000000000000000000000000000000000000"
Set ObjectStream = CreateObject("ADODB.Stream")
Set ObjectDOM = CreateObject("Microsoft.XMLDOM")
Set ObjectElement = ObjectDOM.createElement("TMP")
Set ObjectHTTP = CreateObject("Microsoft.XMLHTTP")
'Reading binary file
ObjectStream.Open
ObjectStream.Type = 1 'Type Binary
ObjectStream.LoadFromFile (strLocalFile)
BinaryFile = ObjectStream.Read()
ObjectStream.Close
'Conversion Base64
ObjectElement.DataType = "bin.base64" 'Type Base64
ObjectElement.nodeTypedValue = BinaryFile
EncodedFile = ObjectElement.Text
'Build request to load document
strURLService = spBASE_URL + "_vti_bin/copy.asmx"
strSOAPAction = "http://schemas.microsoft.com/sharepoint/soap/CopyIntoItems"
strSOAPCommand = "<?xml version='1.0' encoding='utf-8'?>" & _
"<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>" & _
"<soap:Body>" & _
"<CopyIntoItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>" & _
"<SourceUrl>" + strLocalFile + "</SourceUrl>" & _
"<DestinationUrls>" & _
"<string>" + spBASE_URL + spDOC_LIB + "/" + spFILE_NAME + "</string>" & _
"</DestinationUrls>" & _
"<Fields>" & _
"<FieldInformation Type='Text' InternalName='Title' DisplayName='Title' Value='this is the title value' />" & _
"<FieldInformation Type='Choice' InternalName='Our_x0020_Status' DisplayName='Our Document Status' Value='Ready-to-distribute' />" & _
"<FieldInformation Type='Text' InternalName='ContentTypeId' DisplayName='Content Type ID' Value='" + spCONTENT_TYPE + "' />" & _
"</Fields>" & _
"<Stream>" + EncodedFile + "</Stream>" & _
"</CopyIntoItems>" & _
"</soap:Body>" & _
"</soap:Envelope>"
ObjectHTTP.Open "Get", strURLService, False
ObjectHTTP.SetRequestHeader "Content-Type", "text/xml; charset=utf-8"
ObjectHTTP.SetRequestHeader "SOAPAction", strSOAPAction
ObjectHTTP.Send strSOAPCommand
MsgBox (ObjectHTTP.responseText)
End Sub
Maybe you are looking for
-
Recosting material after cost release - Follow-up re MBEW/HKMAT field
When we set standards this year, I did not know that this field should have had its value set before costing, and it is now not showing the material number in variance calculations for the ten or so items that did not have the flag set. My question i
-
How to save fillable PDF on Mac then share or send
Question I followed instructions to select print, select the Save as PDF but when I tried to send the completed fillable PDF; the blanks are empty. I can't even open the saved document that shows there is information saved. When I try to open, ther
-
In support whether we do data transfer or not?
hi experts, i heard from my friend, that all the data transfers will be completed before the go live and no data transfer will take place after that or in support. so i have doubt regarding this. whether in support project will there be any of data t
-
Hello Everyone I am facing router sync problem at a customer side RouterA is INSVC with PG's 3/3 and Router B showing OOSVC rb-rtr Peripheral CVP4 (ID 5004) is on-line. 02:04:17:122 rb-rtr Peripheral CVP4 (ID 5004) still in time interval 03/15/2012 2
-
Flash C5 pro used to create feature length animated films
First, I have Adobe Production Suite CS5 on it's way and have been loooking for information on using several of the programs like Flash, Photoshop, Illustrator, After Effects and Premiere. How is Flash C5 pro used to create feature length animated fi