Subir una base.dbf a una carpeta en la nube
Subir una base.dbf a una carpeta en la nube
Buenas estimados
Necesito subir una base.dbf que es actualizada por una aplicación de escritorio para luego mostrarla con Mod_Harbour
desde cualquier dispositivo
La dirección es:
http://190.171.250.71/admcon
O poder abrirla desde la nube con una aplicación de escritorio.
Muchas gracias por la ayuda
Necesito subir una base.dbf que es actualizada por una aplicación de escritorio para luego mostrarla con Mod_Harbour
desde cualquier dispositivo
La dirección es:
http://190.171.250.71/admcon
O poder abrirla desde la nube con una aplicación de escritorio.
Muchas gracias por la ayuda
Saludos,
Adhemar C.
Adhemar C.
- Antonio Linares
- Site Admin
- Posts: 42597
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 40 times
- Been thanked: 86 times
- Contact:
Re: Subir una base.dbf a una carpeta en la nube
Adhemar,
En el ejemplo https://www.modharbour.org/modharbour_samples/modpro/modpro.prg usamos esta función en javascript
para seleccionar un DBF (opción "open" desde el menu) y enviarlo al servidor:
el fichero upload.prg se encarga de recibir el DBF y salvarlo en el servidor:
https://github.com/FiveTechSoft/mod_harbour/blob/master/samples/modpro/upload.prg
En el ejemplo https://www.modharbour.org/modharbour_samples/modpro/modpro.prg usamos esta función en javascript
para seleccionar un DBF (opción "open" desde el menu) y enviarlo al servidor:
Code: Select all | Expand
function OpenDbf()
{
var oFile;
oFPicker = document.createElement( "input" );
oFPicker.type = "file";
oFPicker.accept = ".dbf,.dbt,.fpt,.cdx,.ntx";
oFPicker.style.visibility = "hidden";
oFPicker.onchange = function( evt ){
var reader = new FileReader();
oFile = evt.target.files[0];
reader.readAsDataURL( oFile );
reader.onload = function( e ) {
var formData = new FormData();
var xhr = new XMLHttpRequest();
var blob = new Blob( [e.target.result], {type: "application/octet-stream"} );
formData.append( oFile.name, blob );
xhr.onreadystatechange = function() {
if( this.readyState == XMLHttpRequest.DONE && this.status == 200 ) {
Command( this.responseText, true ); } };
xhr.open( "POST", 'upload.prg' );
xhr.send( formData );
}
};
oFPicker.click();
}
el fichero upload.prg se encarga de recibir el DBF y salvarlo en el servidor:
https://github.com/FiveTechSoft/mod_harbour/blob/master/samples/modpro/upload.prg
Re: Subir una base.dbf a una carpeta en la nube
Estimado Antonio
Me podría pasar un ejemplo directo sin Modpro
No se como ejecutar la función de javascript
Gracias por la ayuda
Me podría pasar un ejemplo directo sin Modpro
No se como ejecutar la función de javascript
Gracias por la ayuda
Saludos,
Adhemar C.
Adhemar C.
- Antonio Linares
- Site Admin
- Posts: 42597
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 40 times
- Been thanked: 86 times
- Contact:
Re: Subir una base.dbf a una carpeta en la nube
Adhemar,
Puedes llamar la función en javascript desde un botón, por ejemplo:
Puedes llamar la función en javascript desde un botón, por ejemplo:
Code: Select all | Expand
function Main()
? [<button onclick="OpenDbf()">subir fichero</button>]
return nil
Re: Subir una base.dbf a una carpeta en la nube
Muchas Gracias Estimado Antonio
Lo he realizado así:
Y me sale éste error:
Error: Incomplete statement or unbalanced delimiters
operation: line:9
called from: HB_COMPILEFROMBUF, line: 0
called from: ..\source\exec.prg, EXECUTE, line: 68
Gracias por la ayuda
Lo he realizado así:
Code: Select all | Expand
function Main()
? [<button onclick="OpenDbf()">subir fichero</button>]
return nil
*
Function OpenDbf()
{
var oFile;
oFPicker = document.createElement( "input" );
oFPicker.type = "file";
oFPicker.accept = ".dbf,.dbt,.fpt,.cdx,.ntx";
oFPicker.style.visibility = "hidden";
oFPicker.onchange = function( evt ){
var reader = new FileReader();
oFile = evt.target.files[0];
reader.readAsDataURL( oFile );
reader.onload = function( e ) {
var formData = new FormData();
var xhr = new XMLHttpRequest();
var blob = new Blob( [e.target.result], {type: "application/octet-stream"} );
formData.append( oFile.name, blob );
xhr.onreadystatechange = function() {
if( this.readyState == XMLHttpRequest.DONE && this.status == 200 ) {
Command( this.responseText, true ); } };
xhr.open( "POST", 'upload.prg' );
xhr.send( formData );
}
};
oFPicker.click();
}
Return
Y me sale éste error:
Error: Incomplete statement or unbalanced delimiters
operation: line:9
called from: HB_COMPILEFROMBUF, line: 0
called from: ..\source\exec.prg, EXECUTE, line: 68
Gracias por la ayuda
Saludos,
Adhemar C.
Adhemar C.
- Otto
- Posts: 6413
- Joined: Fri Oct 07, 2005 7:07 pm
- Has thanked: 28 times
- Been thanked: 2 times
- Contact:
Re: Subir una base.dbf a una carpeta en la nube
Adhemar,
Is OpenDBF() not a javascript function?
You have to tell mod harbour where HTML starts and end.
TEMPLATE
ENDTEXT
And inside HTML code, you have to tell the program where JavaScript starts and end.
<script></script>
Attention JavaScript is case sensitive Function does not work it must be function.
Best regards,
Otto
Is OpenDBF() not a javascript function?
You have to tell mod harbour where HTML starts and end.
TEMPLATE
ENDTEXT
And inside HTML code, you have to tell the program where JavaScript starts and end.
<script></script>
Attention JavaScript is case sensitive Function does not work it must be function.
Best regards,
Otto
Code: Select all | Expand
function Main()
? [<button onclick="OpenDbf()">subir fichero</button>]
TEMPLATE
<script>
function OpenDbf()
{
var oFile;
oFPicker = document.createElement( "input" );
oFPicker.type = "file";
oFPicker.accept = ".dbf,.dbt,.fpt,.cdx,.ntx";
oFPicker.style.visibility = "hidden";
oFPicker.onchange = function( evt ){
var reader = new FileReader();
oFile = evt.target.files[0];
reader.readAsDataURL( oFile );
reader.onload = function( e ) {
var formData = new FormData();
var xhr = new XMLHttpRequest();
var blob = new Blob( [e.target.result], {type: "application/octet-stream"} );
formData.append( oFile.name, blob );
xhr.onreadystatechange = function() {
if( this.readyState == XMLHttpRequest.DONE && this.status == 200 ) {
Command( this.responseText, true ); } };
xhr.open( "POST", 'upload.prg' );
xhr.send( formData );
}
};
oFPicker.click();
}
</script>
ENDTEXT
Return
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
Re: Subir una base.dbf a una carpeta en la nube
Thank you very much Mr. Otto. It works
Can you run the function directly if you need the button?
Thanks for the help
Can you run the function directly if you need the button?
Thanks for the help
Saludos,
Adhemar C.
Adhemar C.
- Otto
- Posts: 6413
- Joined: Fri Oct 07, 2005 7:07 pm
- Has thanked: 28 times
- Been thanked: 2 times
- Contact:
Re: Subir una base.dbf a una carpeta en la nube
Adhemar,
I tried but get:
File chooser dialog can only be shown with a user activation.
I don't know if this is out of security reasons, possible.
Maybe with a workaround
Best regards,
Otto
I tried but get:
File chooser dialog can only be shown with a user activation.
I don't know if this is out of security reasons, possible.
Maybe with a workaround
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
Re: Subir una base.dbf a una carpeta en la nube
Thanks Dear Otto.
What I need is to upload 3 specific files automatically. The desktop system user only has to click on the link and return a "READY" message. And if possible, run the link from the desktop application.
Thank you very much for the help.
What I need is to upload 3 specific files automatically. The desktop system user only has to click on the link and return a "READY" message. And if possible, run the link from the desktop application.
Thank you very much for the help.
Saludos,
Adhemar C.
Adhemar C.
- Otto
- Posts: 6413
- Joined: Fri Oct 07, 2005 7:07 pm
- Has thanked: 28 times
- Been thanked: 2 times
- Contact:
Re: Subir una base.dbf a una carpeta en la nube
Ademar,
I think that's difficult for security reasons.
I did some tests today.
What I managed to do is to send a txt or json file.
I exported the DBF file to TXT and json-encoded the file.
I read the TXT file into a variable, and then I make a FORMDATA object that I upload with AJAX.
At the backend, you then have the entire harbor scope and can format the result.
Besst regards,
Otto
upload.prg
data.prg
I think that's difficult for security reasons.
I did some tests today.
What I managed to do is to send a txt or json file.
I exported the DBF file to TXT and json-encoded the file.
I read the TXT file into a variable, and then I make a FORMDATA object that I upload with AJAX.
At the backend, you then have the entire harbor scope and can format the result.
Besst regards,
Otto
upload.prg
Code: Select all | Expand
function main()
TEMPLATE
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Ihre Anmeldung</title>
</head>
<body>
<script src="assets/js/jquery.min.js"></script>
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
<script>
var allText ="";
function readTextFile(file)
{
var rawFile = new XMLHttpRequest();
rawFile.open("GET", file);
rawFile.onreadystatechange = function ()
{
if(rawFile.readyState === 4)
{
if(rawFile.status === 200 || rawFile.status == 0)
{
allText = rawFile.responseText;
}
}
}
rawFile.send(null);
}
//var file ="newfile.txt";
var file ="customer.json";
readTextFile( file );
$( document ).ready(function() {
console.log( "ready!" );
var fd = new FormData();
fd.append('data',allText);
$.ajax({
type: "post",
url: "https://test.com/modharbour_samples/data.prg",
data: ( fd ),
contentType: false,
processData: false,
success: function(response) {
console.log(response);
}
});
});
</script>
</body>
</html>
ENDTEXT
return NIL
//----------------------------------------------------------------------------------------//
data.prg
Code: Select all | Expand
REQUEST DBFCDX
REQUEST DBFFPT
function main()
local hPairs := AP_Body()
local hdata := {=>}
cLog := ValToChar( hPairs ) + CRLF
MEMOWRIT("c:\www\htdocs\modharbour_samples\log.log" , cLog, .f. )
hData['error'] := 'true'
AP_SetContentType( "application/json" )
?? hb_jsonEncode( hdata, .T. ) // T=pretty
return NIL
//----------------------------------------------------------------------------------------//
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
Re: Subir una base.dbf a una carpeta en la nube
Thank you very much dear Otto
I did it by installing Apache24 on the client and FTP on the server.
With in the program: ftpup.prg.
I run it with:
Thanks for your time and help.
Regards,
I did it by installing Apache24 on the client and FTP on the server.
With in the program: ftpup.prg.
I run it with:
Code: Select all | Expand
Function ActulizaFTP()
Local oHttp
oHttp := CreateObject( "winhttp.winhttprequest.5.1" )
oHttp:Open("GET","http://localhost/admcon/ftpup.prg", .f. )
oHttp:Send()
Return
Thanks for your time and help.
Regards,
Saludos,
Adhemar C.
Adhemar C.
- wilsongamboa
- Posts: 616
- Joined: Wed Oct 19, 2005 6:41 pm
- Location: Quito - Ecuador
- Has thanked: 1 time
- Been thanked: 5 times
Re: Subir una base.dbf a una carpeta en la nube
Adhemar C
buenos dias
me parece mas natural que uses hbnetio y leas directamente la tabla desde mod_harbour queda mas transparente
saludos
Wilson
buenos dias
me parece mas natural que uses hbnetio y leas directamente la tabla desde mod_harbour queda mas transparente
saludos
Wilson
Wilson 'W' Gamboa A
Wilson.josenet@gmail.com
Wilson.josenet@gmail.com
Re: Subir una base.dbf a una carpeta en la nube
Muchas gracias estimado Wilson por el consejo
Podrías poner un ejemplo de como hacerlo con HBNETIO
Muchas gracias por la ayuda.
Podrías poner un ejemplo de como hacerlo con HBNETIO
Muchas gracias por la ayuda.
Saludos,
Adhemar C.
Adhemar C.
- wilsongamboa
- Posts: 616
- Joined: Wed Oct 19, 2005 6:41 pm
- Location: Quito - Ecuador
- Has thanked: 1 time
- Been thanked: 5 times
Re: Subir una base.dbf a una carpeta en la nube
Buenas tardes
hace tiempo hice un pdf donde se explica todo esto, pensando mostrarlo en las charlas de mod_harbour no se como subirlo aca
lo puedes bajar de
http://186.4.197.203/ift/hbnetio.pdf
cualquier duda a las ordenes
Wilson
hace tiempo hice un pdf donde se explica todo esto, pensando mostrarlo en las charlas de mod_harbour no se como subirlo aca
lo puedes bajar de
http://186.4.197.203/ift/hbnetio.pdf
cualquier duda a las ordenes
Wilson
Wilson 'W' Gamboa A
Wilson.josenet@gmail.com
Wilson.josenet@gmail.com
Re: Subir una base.dbf a una carpeta en la nube
Muchas Gracias Estimado Wilson
Lo voy a intentar
Lo voy a intentar
Saludos,
Adhemar C.
Adhemar C.