I am calling a soap base https service from plsql but i am getting not response , Please see below code for calling soap.
PROCEDURE SALES_XML_CUSTOMS_PRC
IS
CURSOR GET_HEADER IS
SELECT COUNT(OSDD.SALE_REF_NO) ITEM_COUNT, SUM(OSDD.DD_QTY) SUM_QTY, OSD.SALE_REF_NO ,'8326' RETAILSTOREID, TO_CHAR(OSD.DOC_DATE,'DD') GUN, TO_CHAR(OSD.DOC_DATE,'MM') AY, TO_CHAR(OSD.DOC_DATE,'YYYY') YIL,
TO_CHAR(OSD.DOC_DATE,'HH') SAAT, TO_CHAR(OSD.DOC_DATE,'MI') DAKIKA, TO_CHAR(OSD.DOC_DATE,'SS') SANIYE,
DECODE(DT_CODE,'IN', 'Z000', 'CR', 'Z005') TRANSTYPECODE, OSD.CREATION_TERM WORKSTATIONID, OSD.DOC_PROV_NO TRANSNUMBER,
TO_CHAR(OSD.DOC_DATE,'YYYYMMDDHHMMSS') BEGINTIMESTAMP, TO_CHAR(OSD.DOC_DATE,'YYYYMMDDHHMMSS') ENDTIMESTAMP, OSD.SM_CODE OPERATORID,
'EUR' TRANSCURRENCY, 1 TENDERNUMBER, 'ZEUR' TENDERTYPECODE,
OSD.DOC_TOTAL_AMOUNT TENDER_AMOUNT, 'EUR' TENDERCURRENCY,
OSEI.NAT_CODE, OSEI.PASSENGER_TYPE, OSEI.GENDER, OSEI.HAS_INFANT, OSEI.HAS_CHILD, OSEI.AIRLINE_CODE, OSEI.DEPARTURE_CODE, OSEI.ARRIVAL_CODE,
OSEI.FLIGHT_NO, OSEI.CASH_NAT_ID, OSEI.DOC_TYPE, OSEI.PASSPORT_NO, OSEI.PAS_SURNAME||OSEI.PAS_NAME PASS_SUR_NAME, OSEI.PAS_DOB,
OSD.DOC_PROV_NO
FROM OFF_SALE_DOCUMENTS#MOSIAT OSD, OFF_SALE_DOCUMENT_DETAILS#MOSIAT OSDD, OFF_SALE_EXTRA_INFO#MOSIAT OSEI, OFF_SENT_SALES#MOSIAT LOG
WHERE 1=1
AND OSD.DOC_PROV_NO = OSDD.DOC_PROV_NO
AND OSD.DEP_CODE = OSDD.DEP_CODE
AND OSD.SALE_REF_NO = OSDD.SALE_REF_NO
AND OSEI.SALE_REf_NO(+) = OSD.SALE_REF_NO
AND OSEI.DOC_PROV_NO(+) = OSD.DOC_PROV_NO
AND OSEI.DEP_CODE(+) = OSD.DEP_CODE
AND OSD.DOC_STATUS = 1
AND OSD.SALE_REF_NO = LOG.SALE_REF_NO
AND OSD.DOC_PROV_NO = LOG.DOC_PROV_NO
AND OSD.DEP_CODE = LOG.DEP_CODE
AND LOG.SENT_FLAG = 0
AND ROWNUM = 1
GROUP BY OSD.SALE_REF_NO ,'8326' , TO_CHAR(OSD.DOC_DATE,'DD') , TO_CHAR(OSD.DOC_DATE,'MM') , TO_CHAR(OSD.DOC_DATE,'YYYY') ,
TO_CHAR(OSD.DOC_DATE,'HH') , TO_CHAR(OSD.DOC_DATE,'MI') , TO_CHAR(OSD.DOC_DATE,'SS') ,
DECODE(DT_CODE,'IN', 'Z000', 'CR', 'Z005') , OSD.CREATION_TERM , OSD.DOC_PROV_NO ,
TO_CHAR(OSD.DOC_DATE,'YYYYMMDDHHMMSS') , TO_CHAR(OSD.DOC_DATE,'YYYYMMDDHHMMSS') , OSD.SM_CODE , 'EUR' , 1 , 'ZEUR' ,
OSD.DOC_TOTAL_AMOUNT , 'EUR' , OSEI.NAT_CODE, OSEI.PASSENGER_TYPE, OSEI.GENDER, OSEI.HAS_INFANT, OSEI.HAS_CHILD,
OSEI.AIRLINE_CODE, OSEI.DEPARTURE_CODE, OSEI.ARRIVAL_CODE, OSEI.FLIGHT_NO, OSEI.CASH_NAT_ID, OSEI.DOC_TYPE, OSEI.PASSPORT_NO,
OSEI.PAS_SURNAME||OSEI.PAS_NAME , OSEI.PAS_DOB, OSD.DOC_PROV_NO
ORDER BY OSD.SALE_REF_NO;
l_output UTL_FILE.file_type;
l_thecursor INTEGER DEFAULT DBMS_SQL.open_cursor;
l_columnvalue VARCHAR2 (2000);
l_status INTEGER;
l_colcnt NUMBER DEFAULT 0;
l_separator VARCHAR2 (10) DEFAULT '';
l_cnt NUMBER DEFAULT 0;
v_xml_header Varchar2(500);
v_xml_detail Varchar2(500);
v_item_barcode VARCHAR2(50);
l_cnt_rec NUMBER DEFAULT 0;
v_depcode VARCHAR2(3);
v_len number;
l_http_request UTL_HTTP.req;
l_http_response UTL_HTTP.resp;
l_buffer_size NUMBER(10) := 30000;
l_line_size NUMBER(10) := 20000;
l_lines_count NUMBER(10) := 1000;
l_string_request VARCHAR2(32767);
l_line VARCHAR2(30000);
l_substring_msg VARCHAR2(30000);
l_raw_data RAW(30000);
l_clob_response CLOB;
-- l_host_name VARCHAR2(128) := '195.128.37.14';
l_host_name VARCHAR2(128) := 'inatestgumrukws.unifree.com.tr';
l_port VARCHAR2(128) := '443'; --80: http, 443: https
l_resp_xml XMLType;
l_result_XML_node VARCHAR2(128);
l_NAMESPACE_SOAP VARCHAR2(128) := 'xmlns:ns0=''urn:sap-com:document:sap:rfc:functions''';
l_response_Customername VARCHAR2(128);
l_response_Cardname VARCHAR2(128);
l_response_points number;
L_AMOUNT NUMBER;
data varchar2(32767);
name VARCHAR2(256);
value VARCHAR2(1024);
i number;
--'https://inatestgumrukws.unifree.com.tr/Services/CustomService.svc',
BEGIN
UTL_HTTP.SET_WALLET('file:/oracle/Certs/wallet', 'aiadmin123');
-- show_html_from_url('https://inatestgumrukws.unifree.com.tr/Services/CustomService.svc');
FOR FETCH_HEADER IN GET_HEADER LOOP
l_string_request := '<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cus="https://unifree.com.tr/services/custom" xmlns:cus1="http://schemas.datacontract.org/2004/07/CustomServiceLibrary.DataContract">
<soapenv:Header/><soapenv:Body><cus:SaveSales><!--Optional:--><cus:salesRequestENDataContract><cus1:Subcontractor>
<cus1:CompanyCode>75</cus1:CompanyCode><cus1:RegionCode>98</cus1:RegionCode><cus1:StoreCode>UMT41</cus1:StoreCode>
<cus1:CashTillCode>1</cus1:CashTillCode><cus1:CashierCode>'||FETCH_HEADER.CASH_NAT_ID||'</cus1:CashierCode></cus1:Subcontractor>
<cus1:SalesDate><cus1:Day>'||FETCH_HEADER.GUN||'</cus1:Day><cus1:Month>'||FETCH_HEADER.AY||'</cus1:Month><cus1:Year>'||FETCH_HEADER.YIL||'</cus1:Year>
<cus1:Hour>'||FETCH_HEADER.SAAT||'</cus1:Hour><cus1:Minute>'||FETCH_HEADER.DAKIKA||'</cus1:Minute><cus1:Second>'||FETCH_HEADER.SANIYE||'</cus1:Second>
</cus1:SalesDate><!--Optional:--><cus1:InvoiceNumber>'||FETCH_HEADER.DOC_PROV_NO||'</cus1:InvoiceNumber><cus1:Customer>
<cus1:IdentityType>'||FETCH_HEADER.DOC_TYPE||'</cus1:IdentityType><cus1:PassportNo>'||FETCH_HEADER.PASSPORT_NO||'</cus1:PassportNo>
<cus1:CustomerName>'||FETCH_HEADER.PASS_SUR_NAME||'</cus1:CustomerName><cus1:DateOfBirth>
<cus1:Day>'||TO_CHAR(FETCH_HEADER.PAS_DOB,'DD')||'</cus1:Day><cus1:Month>'||TO_CHAR(FETCH_HEADER.PAS_DOB,'MM')||'</cus1:Month>
<cus1:Year>'||TO_CHAR(FETCH_HEADER.PAS_DOB,'YYYY')||'</cus1:Year><cus1:Hour>0</cus1:Hour><cus1:Minute>0</cus1:Minute>
<cus1:Second>0</cus1:Second></cus1:DateOfBirth><cus1:PassengerTypeCode>'||FETCH_HEADER.PASSENGER_TYPE||'</cus1:PassengerTypeCode>
<cus1:Arrival_Departure_Code>2</cus1:Arrival_Departure_Code></cus1:Customer><cus1:SalesLine><!--Zero or more repetitions:-->
<cus1:SalesLine><cus1:ProductGroupCode>99</cus1:ProductGroupCode><cus1:SalesQuantity>'||FETCH_HEADER.SUM_QTY||'</cus1:SalesQuantity>
<cus1:LimitUnitQuantity>'||FETCH_HEADER.SUM_QTY||'</cus1:LimitUnitQuantity><!--Optional:--><cus1:DolarAmount>'||FETCH_HEADER.TENDER_AMOUNT*1.12||'</cus1:DolarAmount>
<!--Optional:--><cus1:EuroAmount>'||FETCH_HEADER.TENDER_AMOUNT||'</cus1:EuroAmount></cus1:SalesLine></cus1:SalesLine></cus:salesRequestENDataContract>
</cus:SaveSales></soapenv:Body></soapenv:Envelope>';
UTL_HTTP.SET_TRANSFER_TIMEOUT(200);
l_http_request := UTL_HTTP.BEGIN_REQUEST(url =>
--'http://inatestgumrukws.unifree.com.tr/Services/CustomService.svc?singleWsdl',method => 'POST', http_version => 'HTTP/1.1');
'https://inatestgumrukws.unifree.com.tr/Services/CustomService.svc');
-- method => 'POST')--, http_version => 'HTTP/1.1');
UTL_HTTP.SET_HEADER(l_http_request, 'User-Agent', 'Mozilla/4.0');
-- UTL_HTTP.set_header(l_http_request, 'Host', l_host_name || ':' || l_port);
UTL_HTTP.set_authentication(l_http_request,'75','Test357');
UTL_HTTP.set_header(l_http_request, 'Connection', 'close');
UTL_HTTP.set_header(l_http_request, 'Content-Type', 'text/xml;charset=UTF-8');
UTL_HTTP.set_header(l_http_request, 'SOAPAction', '');
UTL_HTTP.set_header(l_http_request, 'Content-Length', LENGTH(l_string_request));
-- UTL_HTTP.write_text(l_http_request, l_string_request);
DBMS_OUTPUT.put_line('Request>' || l_string_request || '');
DBMS_OUTPUT.put_line('Response> content-length: "' || LENGTH(l_string_request) || '"');
<<request_loop>>
FOR i IN 0..CEIL(LENGTH(l_string_request) / l_buffer_size) - 1 LOOP
l_substring_msg := SUBSTR(l_string_request, i * l_buffer_size + 1, l_buffer_size);
BEGIN
l_raw_data := utl_raw.cast_to_raw(l_substring_msg);
UTL_HTTP.write_raw(r => l_http_request, data => l_raw_data);
EXCEPTION
WHEN NO_DATA_FOUND THEN
EXIT request_loop;
END;
END LOOP request_loop;
l_http_response := UTL_HTTP.get_response(l_http_request);
DBMS_OUTPUT.put_line('Response> status_code: "' || l_http_response.status_code || '"');
DBMS_OUTPUT.put_line('Response> reason_phrase: "' ||l_http_response.reason_phrase || '"');
DBMS_OUTPUT.put_line('Response> http_version: "' ||l_http_response.http_version || '"');
IF l_http_response.status_code = '200' AND l_http_response.reason_phrase = 'OK' THEN
--null;
UPDATE OFF_SENT_SALES#MOSIAT
SET SENT_FLAG = 9
WHERE SALE_REF_NO = FETCH_HEADER.SALE_REF_NO
AND DOC_PROV_NO = FETCH_HEADER.TRANSNUMBER;
END IF;
BEGIN
<<response_loop>>
LOOP
UTL_HTTP.read_raw(l_http_response, l_raw_data, l_buffer_size);
l_clob_response := l_clob_response || UTL_RAW.cast_to_varchar2(l_raw_data);
END LOOP response_loop;
EXCEPTION
WHEN UTL_HTTP.end_of_body THEN
UTL_HTTP.end_response(l_http_response);
END;
DBMS_OUTPUT.put_line('Response> length: "' || LENGTH(l_clob_response) || '"');
-- DBMS_OUTPUT.put_line('Response> ' || (l_clob_response) || '"');
DBMS_OUTPUT.put_line(CHR(10) || '=== Print first ' || l_lines_count || ' lines of HTTP response... ===' || CHR(10) || CHR(10));
FOR i IN 0..CEIL(LENGTH(l_clob_response) / l_line_size) - 1 LOOP
l_line := SUBSTR(l_clob_response, i * l_line_size + 1, l_line_size);
DBMS_OUTPUT.put_line('[' || LPAD(i, 2, '0') || ']: ' || l_line);
EXIT WHEN i > l_lines_count - 1;
END LOOP print_response;
IF l_http_request.private_hndl IS NOT NULL THEN
UTL_HTTP.end_request(l_http_request);
END IF;
IF l_http_response.private_hndl IS NOT NULL THEN
UTL_HTTP.end_response(l_http_response);
END IF;
end loop;
commit;
EXCEPTION
WHEN UTL_HTTP.TOO_MANY_REQUESTS THEN
BEGIN
DBMS_OUTPUT.put_line('Response> status_code: "' || l_http_response.status_code || '"' ||'-error');
DBMS_OUTPUT.put_line('Response> reason_phrase: "' ||l_http_response.reason_phrase || '"');
DBMS_OUTPUT.put_line('Response> http_version: "' ||l_http_response.http_version || '"');
UTL_HTTP.END_RESPONSE(l_http_response);
END ;
WHEN UTL_HTTP.REQUEST_FAILED then
DBMS_OUTPUT.put_line('Response> status_code: "' || l_http_response.status_code || '"' ||'-error');
DBMS_OUTPUT.put_line('Response> reason_phrase: "' ||l_http_response.reason_phrase || '"');
DBMS_OUTPUT.put_line('Response> http_version: "' ||l_http_response.http_version || '"');
END SALES_XML_CUSTOMS_PRC;
I am getting the below response from plsql which is not giving actual results , I want to get reviewed my code by experts that where i am doing mistakes and what exactly is the problem
Sample Response
Response> content-length: "1758"
Response> status_code: "200"
Response> reason_phrase: "OK"
Response> http_version: "HTTP/1.1"
Response> length: "3126"
=== Print first 1000 lines of HTTP response... ===
[00]: <HTML><HEAD><link rel="alternate" type="text/xml" href="https://inatestgumrukws.unifree.com.tr/Services/CustomService.svc?disco"/><STYLE type="text/css">#content{ FONT-SIZE: 0.7em; PADDING-BOTTOM: 2em; MARGIN-LEFT: 30px}BODY{MARGIN-TOP: 0px; MARGIN-LEFT: 0px; COLOR: #000000; FONT-FAMILY: Verdana; BACKGROUND-COLOR: white}P{MARGIN-TOP: 0px; MARGIN-BOTTOM: 12px; COLOR: #000000; FONT-FAMILY: Verdana}PRE{BORDER-RIGHT: #f0f0e0 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #f0f0e0 1px solid; MARGIN-TOP: -5px; PADDING-LEFT: 5px; FONT-SIZE: 1.2em; PADDING-BOTTOM: 5px; BORDER-LEFT: #f0f0e0 1px solid; PADDING-TOP: 5px; BORDER-BOTTOM: #f0f0e0 1px solid; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e5e5cc}.heading1{MARGIN-TOP: 0px; PADDING-LEFT: 15px; FONT-WEIGHT: normal; FONT-SIZE: 26px; MARGIN-BOTTOM: 0px; PADDING-BOTTOM: 3px; MARGIN-LEFT: -30px; WIDTH: 100%; COLOR: #ffffff; PADDING-TOP: 10px; FONT-FAMILY: Tahoma; BACKGROUND-COLOR: #003366}.intro{MARGIN-LEFT: -15px}</STYLE><TITLE>CustomServiceEN Service</TITLE></HEAD><BODY><DIV id="content"><P class="heading1">CustomServiceEN Service</P>
<BR/><P class="intro">You have created a service.<P class='intro'>To test this service, you will need to create a client and use it to call the service. You can do this using the svcutil.exe tool from the command line with the following syntax:</P> <BR/><PRE>svcutil.exe https://inatestgumrukws.unifree.com.tr/Services/CustomService.svc?wsdl</PRE><P>You can also access the service description as a single file:<BR/><PRE>https://inatestgumrukws.unifree.com.tr/Services/CustomService.svc?singleWsdl</PRE></P></P><P class="intro"/>This will generate a configuration file and a code file that contains the client class. Add the two files to your client application and use the generated client class to call the Service. For example:<BR/><P class='intro'>
<B>C#</B></P><PRE><font color="blue">class </font><font color="teal">Test
</font>{
<font color="blue"> static void </font>Main()
{
<font color="teal">CustomServiceENClient</font> client = <font color="blue">new </font><font color="teal">CustomServiceENClient</font>();
<font color="green"> // Use the 'client' variable to call operations on the service.
</font><font color="green"> // Always close the client.
</font> client.Close();
}
}
</PRE><BR/><P class='intro'><B>Visual Basic</B></P><PRE><font color="blue">Class </font><font color="teal">Test
</font><font color="blue"> Shared Sub </font>Main()
<font color="blue"> Dim </font>client As <font color="teal">CustomServiceENClient</font> = <font color="blue">New </font><font color="teal">CustomServiceENClient</font>()
<font color="green"> ' Use the 'client' variable to call operations on the service.
</font><font color="green"> ' Always close the client.
</font> client.Close()
<font color="blue"> End Sub
</font><font color="blue">End Class</font></PRE></DIV></BODY></HTML>
SOAPAction
soapAction="https://unifree.com.tr/services/custom/ICustomServiceEN/QueryLimit" style="document"/>
soapAction="https://unifree.com.tr/services/custom/ICustomServiceEN/QueryLimitOnlyForOtherCompanies" style="document"/>
soapAction="https://unifree.com.tr/services/custom/ICustomServiceEN/SaveSales" style="document"/>
soapAction="https://unifree.com.tr/services/custom/ICustomServiceEN/CancelSales" style="document"/>
soapAction="https://unifree.com.tr/services/custom/ICustomServiceEN/GetCulture" style="document"/>
soapAction="https://unifree.com.tr/services/custom/ICustomServiceEN/QueryLimit" style="document"/>
soapAction="https://unifree.com.tr/services/custom/ICustomServiceEN/QueryLimitOnlyForOtherCompanies" style="document"/>
soapAction="https://unifree.com.tr/services/custom/ICustomServiceEN/SaveSales" style="document"/>
soapAction="https://unifree.com.tr/services/custom/ICustomServiceEN/CancelSales" style="document"/>
soapAction="https://unifree.com.tr/services/custom/ICustomServiceEN/GetCulture" style="document"/>
soapAction="https://unifree.com.tr/services/custom/ICustomServiceEN/QueryLimit" style="document"/>
soapAction="https://unifree.com.tr/services/custom/ICustomServiceEN/QueryLimitOnlyForOtherCompanies" style="document"/>
soapAction="https://unifree.com.tr/services/custom/ICustomServiceEN/SaveSales" style="document"/>
soapAction="https://unifree.com.tr/services/custom/ICustomServiceEN/CancelSales" style="document"/>
soapAction="https://unifree.com.tr/services/custom/ICustomServiceEN/GetCulture" style="document"/>
Reason may be due to empty SOAPAction url. Based on your sample response i can see the WSDL Url, click on the WSDL url -> https://inatestgumrukws.unifree.com.tr/Services/CustomService.svc?wsdl and search for SOAPAction and copy the URL to the below code and try again. Hope this helps you.
UTL_HTTP.set_header(l_http_request, 'SOAPAction', '<SOAPActionUrl>');
Related
This question already has answers here:
'google-cloud-firestore' distribution doesn't get added to PyInstaller build
(3 answers)
Closed 3 years ago.
I am using a lot of dependencies for my python project. I am using firestore, pyqt5, numpy and some others. I tried creating an executable file using Pyinstaller but whenever I run the file it says "failed to execute script.
Also I am using images folder and 2 other python file as imports in my main.py file
I tried using hidden imports and still wouldn't work. Is there any easy way to create a pyqt5+firestore project?
Main.py
from PyQt5 import QtWidgets
from HomePage import Ui_HomePage
from attendance import Ui_Dialog
class Firstwindow(QtWidgets.QMainWindow, Ui_HomePage):
def __init__(self, parent=None):
super(Firstwindow, self).__init__(parent)
self.setupUi(self)
self.viewAttendance.clicked.connect(self.hide)
class Secondwindow(QtWidgets.QDialog, Ui_Dialog):
def __init__(self, parent=None):
super(Secondwindow, self).__init__(parent)
self.setupUi(self)
self.backButton.clicked.connect(self.hide)
class Manager:
def __init__(self):
self.first = Firstwindow()
self.second = Secondwindow()
self.first.viewAttendance.clicked.connect(self.second.show)
self.second.backButton.clicked.connect(self.first.show)
self.first.show()
if __name__ == '__main__':
import sys
app = QtWidgets.QApplication(sys.argv)
manager = Manager()
sys.exit(app.exec_())
attendance.py
from PyQt5 import QtCore, QtGui, QtWidgets
import firebase_admin
import google.cloud
from firebase_admin import credentials, firestore
cred = credentials.Certificate("******")
app1 = firebase_admin.initialize_app(cred)
"""Creating a database and authorization object"""
DB = firestore.client()
ids = []
names = []
age = []
job = []
phone = []
year = []
date = []
shiftStart = []
shiftEnd = []
store = firestore.client()
peopleRef = store.collection(u'People')
salaryRef = store.collection('Salary')
jobRef = store.collection('Jobs')
recordRef = store.collection('Records')
dates = recordRef.stream()
for dat in dates:
x = store.collection('Records').document(dat.id).collection('Present')
idx = x.stream()
for i in idx:
print(i.id)
print(i.to_dict()['Name'])
jo = jobRef.stream()
for doc in jo:
fo = doc.id
print(fo)
def getData():
try:
docs = peopleRef.stream()
for doc in docs:
ids.append(doc.id)
names.append(doc.to_dict()['Name'])
job.append(doc.to_dict()['Age'])
age.append(doc.to_dict()['Job Type'])
phone.append(doc.to_dict()['Phone'])
except google.cloud.exceptions.NotFound:
print(u'Missing data')
return ids,names,job,age,phone
def clearData():
ids.clear()
names.clear()
age.clear()
job.clear()
phone.clear()
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(595, 337)
Dialog.setWindowFlag(QtCore.Qt.WindowContextHelpButtonHint,False)
self.gridLayout_2 = QtWidgets.QGridLayout(Dialog)
self.gridLayout_2.setObjectName("gridLayout_2")
self.gridLayout = QtWidgets.QGridLayout()
self.gridLayout.setObjectName("gridLayout")
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.gridLayout.addItem(spacerItem, 0, 5, 1, 1)
spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.gridLayout.addItem(spacerItem1, 0, 3, 1, 1)
self.dateEdit = QtWidgets.QDateEdit(Dialog)
self.dateEdit.setStyleSheet("font: 10pt \"Verdana\";")
self.dateEdit.setObjectName("dateEdit")
self.gridLayout.addWidget(self.dateEdit, 0, 6, 1, 1)
self.refreshButton = QtWidgets.QPushButton(Dialog)
self.refreshButton.setStyleSheet("qproperty-icon:url(:/images/icons/refresh.png);\n"
"background-color: rgb(255, 255, 255);")
self.refreshButton.setText("")
self.refreshButton.setIconSize(QtCore.QSize(20, 20))
self.refreshButton.setFlat(False)
self.refreshButton.setObjectName("refreshButton")
self.gridLayout.addWidget(self.refreshButton, 0, 4, 1, 1)
self.searchDate = QtWidgets.QPushButton(Dialog)
self.searchDate.setStyleSheet("QPushButton {\n"
" color: rgb(0,0,0);\n"
" border: 2px solid #555;\n"
" border-radius: 20px;\n"
" border-style: outset;\n"
" background: rgb(215, 252, 255);\n"
" padding: 5px;\n"
" font: 75 8pt \"Georgia\";\n"
" }\n"
"\n"
"QPushButton:hover {\n"
" background: rgb(111, 210, 255)\n"
" }\n"
"\n"
"QPushButton:pressed {\n"
" border-style: inset;\n"
" background: rgb(111, 210, 255)\n"
" }\n"
"")
self.searchDate.setObjectName("searchDate")
self.gridLayout.addWidget(self.searchDate, 0, 7, 1, 1)
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
self.backButton = QtWidgets.QPushButton(Dialog)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.backButton.sizePolicy().hasHeightForWidth())
self.backButton.setSizePolicy(sizePolicy)
self.backButton.setStyleSheet("qproperty-icon:url(:/images/icons/back.jpg);\n"
"background-color: rgb(255, 255, 255);")
self.backButton.setText("")
self.backButton.setObjectName("backButton")
self.horizontalLayout.addWidget(self.backButton)
self.nameEntry = QtWidgets.QLineEdit(Dialog)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.nameEntry.sizePolicy().hasHeightForWidth())
self.nameEntry.setSizePolicy(sizePolicy)
self.nameEntry.setStyleSheet("font: 10pt \"Verdana\";")
self.nameEntry.setObjectName("nameEntry")
self.horizontalLayout.addWidget(self.nameEntry)
self.gridLayout.addLayout(self.horizontalLayout, 0, 0, 1, 1)
self.searchName = QtWidgets.QPushButton(Dialog)
self.searchName.setStyleSheet("QPushButton {\n"
" color: rgb(0,0,0);\n"
" border: 2px solid #555;\n"
" border-radius: 20px;\n"
" border-style: outset;\n"
" background: rgb(215, 252, 255);\n"
" padding: 5px;\n"
" font: 75 8pt \"Georgia\";\n"
" }\n"
"\n"
"QPushButton:hover {\n"
" background: rgb(111, 210, 255)\n"
" }\n"
"\n"
"QPushButton:pressed {\n"
" border-style: inset;\n"
" background: rgb(111, 210, 255)\n"
" }\n"
"")
self.searchName.setObjectName("searchName")
self.gridLayout.addWidget(self.searchName, 0, 1, 1, 1)
self.profileTree = QtWidgets.QTableWidget(Dialog)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.profileTree.sizePolicy().hasHeightForWidth())
self.profileTree.setSizePolicy(sizePolicy)
self.profileTree.setObjectName("profileTree")
self.gridLayout.addWidget(self.profileTree, 1, 0, 1, 1)
self.dataTree = QtWidgets.QTableWidget(Dialog)
self.dataTree.setObjectName("dataTree")
self.gridLayout.addWidget(self.dataTree, 1, 1, 1, 7)
self.gridLayout_2.addLayout(self.gridLayout, 0, 0, 1, 1)
self.dataTree.setColumnCount(0)
self.dataTree.setRowCount(0)
self.profileTree.setRowCount(0)
self.profileTree.setColumnCount(0)
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
self.profileTree.setEditTriggers(QtWidgets.QTableWidget.NoEditTriggers)
self.refreshButton.clicked.connect(self.refresh)
self.profileTree.cellDoubleClicked.connect(self.showClicked)
def showClicked(self,row,col):
idx = self.profileTree.item(row,0).text()
print(idx)
def refresh(self):
profileData = getData()
self.profileTree.setRowCount(len(profileData[0]))
self.profileTree.setColumnCount(2)
self.profileTree.setHorizontalHeaderLabels(('ID', 'Name'))
for row in range(len(profileData[0])):
for col in range(2):
self.profileTree.setItem(row,col,QtWidgets.QTableWidgetItem(profileData[col][row]))
clearData()
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.searchDate.setText(_translate("Dialog", "Search"))
self.searchName.setText(_translate("Dialog", "Search"))
import images
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
Dialog = QtWidgets.QDialog()
ui = Ui_Dialog()
ui.setupUi(Dialog)
Dialog.show()
sys.exit(app.exec_())
Ok so after hours of research I found this post - 'google-cloud-firestore' distribution doesn't get added to PyInstaller build
The problem was with firestore and not PyQt.
My program uses Indy 10 TIdSMTP and TIdMessage to send error reports via email. The program is used mainly in Germany, but some clients are in the USA.
The tool works flawlessly in Germany, but the USA clients are not able to send anything at all. The output shows that the connection to the German email server (smtp.web.de) is made, but after that, an immediate disconnect follows. The exception "Socket error #10054 connection reset by peer" is thrown.
Here's some code:
procedure SendMail(const PI_sSenderAddress: string; const PI_arrReceiverAddresses, PI_arrCCAddresses, PI_arrBCCAddresses: array of string; const PI_sSubject, PI_sMailText: string; const PI_arrAttachments: array of string; const PI_sHost: string = ''; const PI_sUsername: string = ''; const PI_sPassword: string = ''; const PI_bUseTLS: boolean = False; const PI_nPort: integer = 25; const PI_nTimeoutSeconds: integer = 5 );
var
smtp: TIdSMTP;
Mail: TIdMessage;
i: integer;
arrAttachments: array of TIdAttachmentFile;
io: TIdSSLIOHandlerSocketOpenSSL;
begin
io := nil;
smtp := TIdSMTP.Create(Application);
try
smtp.Password := PI_sPassword;
smtp.Username := PI_sUsername;
smtp.Port := PI_nPort;
smtp.Host := PI_sHost;
if PI_bUseTLS then begin
io := TIdSSLIOHandlerSocketOpenSSL.Create(Application);
smtp.IOHandler := io;
end;
smtp.UseTLS := utUseRequireTLS;
if PI_sUserName <> '' then begin
smtp.AuthType := satDefault;
end else begin
smtp.AuthType := satNone;
end;
smtp.HeloName := Split(PI_sUsername, 1, '#');
mail := TIdMessage.Create( Application );
try
mail.Clear;
mail.From.Address := PI_sSenderAddress;
mail.From.Text := PI_sSenderAddress;
mail.Subject := PI_sSubject;
mail.Recipients.EMailAddresses := ArrayToStr( PI_arrReceiverAddresses, ',' ); //!! only one
mail.CCList.EMailAddresses := ArrayToStr( PI_arrCCAddresses, ',' );
mail.BccList.EMailAddresses := ArrayToStr( PI_arrBCCAddresses, ',' );
mail.ReceiptRecipient.Text := '';
mail.Body.Add( PI_sMailText );
mail.Date := now;
if Length(PI_arrAttachments) > 0 then begin
SetLength(arrAttachments, Length(PI_arrAttachments));
for i := 0 to High(PI_arrAttachments) do begin
arrAttachments[i] := TIdAttachmentFile.Create(mail.MessageParts, PI_arrAttachments[i]);
end;
end;
try
smtp.ConnectTimeout := PI_nTimeoutSeconds * 1000;
smtp.Connect;
if smtp.Connected then begin
smtp.Send(mail);
end;
finally
smtp.disconnect;
if Length(arrAttachments) > 0 then begin
for i := 0 to High(arrAttachments) do begin
arrAttachments[i].Free;
end;
end;
end;
finally
mail.Free;
end;
finally
smtp.free;
if Assigned(io) then io.Free;
end;
end;
I call it like this:
SendMail(
'myaccount#web.de',
['receiver#web.de'],
[],
[],
'Subject',
'Text',
[],
'smtp.web.de',
'myaccount#web.de',
'mypassword',
True,
587
);
Can someone help?
EDIT: I changed to a googlemail account, but getting the same error. Currently, i call it like this:
I call it like this:
SendMail(
'myaccount#gmail.com',
['receiver#web.de'],
[],
[],
'Subject',
'Text',
[],
'smtp.gmail.com',
'myaccount#gmail.com',
'mypassword',
True,
587
);
I want to Insert record and upload file at the same time, right now im using FreeASPUpload Script. When i submit the form it returns this error
Cannot use the generic Request collection after calling BinaryRead
Here is the Full Source Code of my page
<%
option explicit
Response.Expires = -1
Server.ScriptTimeout = 600
Session.CodePage = 65001
%>
<!-- #include file="UploadClass.asp" -->
<%
Dim uploadsDirVar
uploadsDirVar = server.MapPath("Files_Uploaded")
function OutputForm()
%>
<form name="frmSend" method="POST" enctype="multipart/form-data" accept-charset="utf-8" action="form.asp" onSubmit="return onSubmitForm();">
<input type="hidden" name="ApplicationForm" value="Insert" />
Name: <input type="text" name="name_insert" value="" size="30" />
<B>File names:</B><br>
File 1: <input name="attach1" type="file" size=35><br>
<br>
<input style="margin-top:4" type="submit" value="Submit">
</form>
<%
end function
function TestEnvironment()
Dim fso, fileName, testFile, streamTest
TestEnvironment = ""
Set fso = Server.CreateObject("Scripting.FileSystemObject")
if not fso.FolderExists(uploadsDirVar) then
TestEnvironment = "<B>Folder " & uploadsDirVar & " does not exist.</B><br>The value of your uploadsDirVar is incorrect. Open uploadTester.asp in an editor and change the value of uploadsDirVar to the pathname of a directory with write permissions."
exit function
end if
fileName = uploadsDirVar & "\test.txt"
on error resume next
Set testFile = fso.CreateTextFile(fileName, true)
If Err.Number<>0 then
TestEnvironment = "<B>Folder " & uploadsDirVar & " does not have write permissions.</B><br>The value of your uploadsDirVar is incorrect. Open uploadTester.asp in an editor and change the value of uploadsDirVar to the pathname of a directory with write permissions."
exit function
end if
Err.Clear
testFile.Close
fso.DeleteFile(fileName)
If Err.Number<>0 then
TestEnvironment = "<B>Folder " & uploadsDirVar & " does not have delete permissions</B>, although it does have write permissions.<br>Change the permissions for IUSR_<I>computername</I> on this folder."
exit function
end if
Err.Clear
Set streamTest = Server.CreateObject("ADODB.Stream")
If Err.Number<>0 then
TestEnvironment = "<B>The ADODB object <I>Stream</I> is not available in your server.</B><br>Check the Requirements page for information about upgrading your ADODB libraries."
exit function
end if
Set streamTest = Nothing
end function
function SaveFiles
Dim Upload, fileName, fileSize, ks, i, fileKey
Set Upload = New FreeASPUpload
Upload.Save(uploadsDirVar)
' If something fails inside the script, but the exception is handled
If Err.Number<>0 then Exit function
SaveFiles = ""
ks = Upload.UploadedFiles.keys
if (UBound(ks) <> -1) then
SaveFiles = "<B>Files uploaded:</B> "
for each fileKey in Upload.UploadedFiles.keys
SaveFiles = SaveFiles & Upload.UploadedFiles(fileKey).FileName & " (" & Upload.UploadedFiles(fileKey).Length & "B) "
next
else
SaveFiles = "No file selected for upload or the file name specified in the upload form does not correspond to a valid file in the system."
end if
SaveFiles = SaveFiles & "<br>Enter a number = " & Upload.Form("enter_a_number") & "<br>"
SaveFiles = SaveFiles & "Checkbox values = " & Upload.Form("checkbox_values") & "<br>"
SaveFiles = SaveFiles & "List values = " & Upload.Form("list_values") & "<br>"
SaveFiles = SaveFiles & "Text area = " & Upload.Form("t_area") & "<br>"
end function
%>
<HTML>
<HEAD>
<TITLE>Test Free ASP Upload 2.0</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
BODY {background-color: white;font-family:arial; font-size:12}
</style>
<script>
function onSubmitForm() {
var formDOMObj = document.frmSend;
if (formDOMObj.attach1.value == "")
alert("Please press the Browse button and pick a file.")
else
return true;
return false;
}
</script>
</HEAD>
<BODY>
<br><br>
<div style="border-bottom: #A91905 2px solid;font-size:16">Upload files to your server</div>
<%
Dim diagnostics
if Request.ServerVariables("REQUEST_METHOD") <> "POST" then
diagnostics = TestEnvironment()
if diagnostics<>"" then
response.write "<div style=""margin-left:20; margin-top:30; margin-right:30; margin-bottom:30;"">"
response.write diagnostics
response.write "<p>After you correct this problem, reload the page."
response.write "</div>"
else
response.write "<div style=""margin-left:150"">"
OutputForm()
response.write "</div>"
end if
else
response.write "<div style=""margin-left:150"">"
OutputForm()
response.write SaveFiles()
response.write "<br><br></div>"
end if
%>
</BODY>
</HTML>
<!-- #include file="ADOVBS.inc" -->
<%
'=======================================================================================
' CONNECT DATABASE
'=======================================================================================
Dim objConn, objRs
Set objConn = CreateObject("ADODB.Connection")
Set objRs = CreateObject("ADODB.Recordset")
objConn.open"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="& server.MapPath("db/Job_database.mdb") &";Mode=ReadWrite|Share Deny None;Persist Security Info=False"
If Request("ApplicationForm") = "Insert" Then
Set InsCom=Server.CreateObject("ADODB.Command")
InsCom.ActiveConnection=objConn
InsName = Trim(request("name_insert"))
InsName = replace(InsName,"'","''")
InsCom.CommandText = "Insert into applications(aname)Values(?)"
InsCom.Parameters.Append InsCom.CreateParameter("#name_insert", adVarChar, adParamInput, 255, InsName)
InsCom.Execute
End If
%>
I have been searching for this problem, but couldn't make it work. although what i found is that i have to use the Form Collection provided by FreeASPUpload. therefore i change
If Request("ApplicationForm") = "Insert" Then
to this
If Upload.Form("ApplicationForm") = "Insert" Then
But it also returns an error, that says: Variable is undefined: 'Upload'
If i change the Request method, it only Uploads the file not inserts the record
If Request.QueryString("ApplicationForm") = "Insert" Then
What i understands is that my insert query is in wrong place or so...
Please help me solve this problem.. thanks
I haven't used AspFreeUpload much so I'm guessing a bit here.
It would appear that using the Request object isn't an option so you're stuck with having to use the Upload.Form. As your code stands, the Upload object is only defined and set within the context of your SaveFiles function.
Try moving your database insert code to within the SaveFiles function. This would mean cutting everything from the line
Dim objConn, objRs
to
InsCom.Execute
and pasting it just before 'End Function'
You may also need to move your include adovbs.inc directive to somewhere before the function was called. The most logical place would be on the line immediately below your other include directive = for uploadclass.asp
I am getting compiling errors in all my CSS files at the line of "filter: progid: DXImageTransform.Microsoft.gradient". Here is an example of my CSS and the error I get on Eclipse for this GWT project. Can you see why?
Error:
Invoking generator com.google.gwt.resources.rebind.context.InlineClientBundleGenerator
Preparing method style
The following problems were detected
[WARN] Line 25 column 9: encountered ":". Was expecting one of: "}" "+" "-" "," ";" "/" <STRING> <IDENT> <NUMBER> <URL> <PERCENTAGE> <PT> <MM> <CM> <PC> <IN> <PX> <EMS> <EXS> <DEG> <RAD> <GRAD> <MS> <SECOND> <HZ> <KHZ> <DIMEN> <HASH> <IMPORTANT_SYM> <UNICODERANGE> <FUNCTION>
[WARN] Line 139 column 17: encountered ":". Was expecting one of: "}" "+" "-" "," ";" "/" <STRING> <IDENT> <NUMBER> <URL> <PERCENTAGE> <PT> <MM> <CM> <PC> <IN> <PX> <EMS> <EXS> <DEG> <RAD> <GRAD> <MS> <SECOND> <HZ> <KHZ> <DIMEN> <HASH> <IMPORTANT_SYM> <UNICODERANGE> <FUNCTION>
CSS file:
.header {
position:absolute;
top:0px;
heigth:40px;
width:100%;
-webkit-box-shadow: 0 1px 2px rgba(0,0,0,.2);
-moz-box-shadow: 0 1px 2px rgba(0,0,0,.2);
box-shadow: 0 1px 2px rgba(0,0,0,.2);
background: #0a0809; /* Old browsers */
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
background: url(data:image/svg+xml;base64,allthestuffhere==);
background: -moz-linear-gradient(top, #0a0809 0%, #0a0e0a 43%, #292b28 100%, #aebcbf 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#0a0809), color-stop(43%,#0a0e0a), color-stop(100%,#292b28), color-stop(100%,#aebcbf)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #0a0809 0%,#0a0e0a 43%,#292b28 100%,#aebcbf 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #0a0809 0%,#0a0e0a 43%,#292b28 100%,#aebcbf 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #0a0809 0%,#0a0e0a 43%,#292b28 100%,#aebcbf 100%); /* IE10+ */
background: linear-gradient(to bottom, #0a0809 0%,#0a0e0a 43%,#292b28 100%,#aebcbf 100%); /* W3C */
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#0a0809', endColorstr='#aebcbf',GradientType=0 ); /* IE6-8 */
}
Because the filter property doesn't conform to the CSS grammar, use the literal function
filter: literal("progid:DXImageTransform.Microsoft.gradient(startColorstr='#0a0809', endColorstr='#aebcbf',GradientType=0)");
It should be:
filter: progid \:DXImageTransform \.Microsoft \.gradient(startColorstr \='#0a0809', endColorstr \='#aebcbf',GradientType \=0 ); /* IE6-8 */
Using Canvas method toDataURL, I would like to be able to save the image on the server side (using Rails).
With toDataURL string, how to use it in a form that can be seen as a file attachment in a HTML form ?
Solution using jQuery, Paperclip, datafy.rb
http://gist.github.com/397615
Here is my solution:
The problem: Compact uploaded images of any size before sending it to the server, which will save the image.
Files involved: 2 ASP pages: one that will act client-side and another server-side.
The Presentation page:
<html>
<!-- by arturmariojr#gmail.com - on december/2012 -->
<script language='javaScript'>
// Check for the various File API support.
if (window.File && window.FileReader && window.FileList && window.Blob) {
// Great success! All the File APIs are supported.
} else {
alert('Este Browser não suporte a API Files');
}
function Compactar(Elemento) {
var file = document.getElementById(Elemento),
reader = new FileReader(), // métodos assíncronos, por isso os eventos!
form = document.getElementById('frmFotos');
//alert(file.id);
reader.readAsDataURL(file.files[0]); // aqui a abertura do arquivo, que irá disparar a função acima
reader.onloadend = function() { // aqui um evento, que será disparado na primeira linha abaixo da função chamada
var image = new Image();
image.src = reader.result; // vai disparar o tratamento do evento abaixo
image.onload = function() {
var maxWidth = 800,
maxHeight = 600,
width = image.width,
height = image.height;
// calculate the width and height, constraining the proportions
if (width > height) {
if (width > maxWidth) {
//height *= max_width / width;
height = Math.round(height *= maxWidth / width);
width = maxWidth;
}
} else {
if (height > maxHeight) {
//width *= max_height / height;
width = Math.round(width *= maxHeight / height);
height = maxHeight;
}
}
var canvas = document.createElement('canvas');
canvas.width = width;
canvas.height = height;
var ctx = canvas.getContext("2d");
ctx.drawImage(image, 0, 0, maxWidth, maxHeight);
// The resized file ready for upload
var finalFile = canvas.toDataURL("image/jpeg",0.8); //a 80% de qualidade
// aqui cria-se novo input comun!
/*var newinput = document.createElement("input");
newinput.type = 'text';
newinput.name = "edt" & Elemento;
newinput.value = finalFile; // put result from canvas into new hidden input
form.appendChild(newinput);*/
document.getElementById("edtArq_1").value = finalFile;
var preview = document.getElementById('preview');
//alert(preview.id);
preview.appendChild(canvas); // do the actual resized preview
}
}
}
</script>
<html>
<form id="form" action="submit" method="post" accept-charset="utf-8" enctype="multipart/form-data">
<!-- this will be left behind - we don't want to upload Mbytes of information -->
<input type='file' name='Arq_1' id='Arq_1' size='50' onchange='Compactar("Arq_1");'>
<form method="POST" id='frmFotos' action='SalvaArquivo.asp'>
<!-- this could be a hidden element -->
<input name='edtArq_1' id='edtArq_1'><br>
<input type='submit' name ='cmdEnviar' id='cmdEnviar' value='Enviar' >
</form>
<!-- just for you see the new resized image - no upload too -->
<div id="preview"></div>
</html>
The page that will reveive the request from the first page and save the image:
<html>
<!-- by arturmariojr#gmail.com - on december/2012 -->
<!-- this script could be avoided if I had put the img element in the page directly
. By the way, actualyy there's no necessity of showing nothing to user
-->
<script language='JavaScript'>
var newImg = document.createElement("img");
newImg.src = '<%=request.form("edtArq_1")%>';
document.body.appendChild(newImg);
</script>
<body>
<input name='edtOriginal' value='<%=request.form("edtArq_1")%>'>
<%
' the data is encoded, so, we will need to deencode it ...
Function Base64Decode(ByVal base64String)
'rfc1521
'1999 Antonin Foller, Motobit Software, http://Motobit.cz
Const Base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
Dim dataLength, sOut, groupBegin
'remove white spaces, If any
base64String = Replace(base64String, vbCrLf, "")
base64String = Replace(base64String, vbTab, "")
base64String = Replace(base64String, " ", "")
'The source must consists from groups with Len of 4 chars
dataLength = Len(base64String)
If dataLength Mod 4 <> 0 Then
Err.Raise 1, "Base64Decode", "Bad Base64 string."
Exit Function
End If
' Now decode each group:
For groupBegin = 1 To dataLength Step 4
Dim numDataBytes, CharCounter, thisChar, thisData, nGroup, pOut
' Each data group encodes up To 3 actual bytes.
numDataBytes = 3
nGroup = 0
For CharCounter = 0 To 3
' Convert each character into 6 bits of data, And add it To
' an integer For temporary storage. If a character is a '=', there
' is one fewer data byte. (There can only be a maximum of 2 '=' In
' the whole string.)
thisChar = Mid(base64String, groupBegin + CharCounter, 1)
If thisChar = "=" Then
numDataBytes = numDataBytes - 1
thisData = 0
Else
thisData = InStr(1, Base64, thisChar, vbBinaryCompare) - 1
End If
If thisData = -1 Then
Err.Raise 2, "Base64Decode", "Bad character In Base64 string."
Exit Function
End If
nGroup = 64 * nGroup + thisData
Next
'Hex splits the long To 6 groups with 4 bits
nGroup = Hex(nGroup)
'Add leading zeros
nGroup = String(6 - Len(nGroup), "0") & nGroup
'Convert the 3 byte hex integer (6 chars) To 3 characters
pOut = Chr(CByte("&H" & Mid(nGroup, 1, 2))) + _
Chr(CByte("&H" & Mid(nGroup, 3, 2))) + _
Chr(CByte("&H" & Mid(nGroup, 5, 2)))
'add numDataBytes characters To out string
sOut = sOut & Left(pOut, numDataBytes)
Next
Base64Decode = sOut
End Function
' now, we will save the data (new image) using the old FileSystemObject !!!
Set fso = Server.CreateObject ("Scripting.FileSystemObject")
If Err.Number <> 0 Then
Response.write "Não foi possível instanciar objeto fso!<br>" & Err.description
response.end
End if
dim Caminho, objArq
Caminho = Server.MapPath("./images") 'where I saved the new image
response.write Caminho
If Err.Number <> 0 Then
Response.write "Não foi possível localizar caminho! " & Caminho & "<br>" & Err.description & "<br>"
else
Set oFile = fso.CreateTextFile(Caminho & "\Teste.jpg", true)
oFile.Write Base64Decode(replace(request.form("edtArq_1"), "data:image/jpeg;base64,", "")) 'BinaryToString(request.from("edtArq_1"))
If Err.Number <> 0 Then
Response.write "Não foi possível localizar thum(s)!" & Caminho & "<br>" & Err.description & "<br>"
end if
oFile.close
end if
%>
</body>
</html>