FiveWeb Questions

Re: FiveWeb Questions

Postby Jeff Barnes » Wed Feb 17, 2016 7:58 pm

I have the file uploading working ...

Inside dialog setup:
Code: Select all  Expand view

?'<form action="../upload.php" method="post" enctype="multipart/form-data">'
    ?'<input type="file" name="file" id="file">'
    ?'<input type="submit" value="Upload Report" name="submit">'
?'</form>'
 


PHP Code:
Code: Select all  Expand view

<?php
 
 $targetfolder = "PDF/";
 
 $targetfolder = $targetfolder . basename( $_FILES['file']['name']) ;
 
 $ok=1;
 
$file_type=$_FILES['file']['type'];
 
if ($file_type=="application/pdf") {
 
 if(move_uploaded_file($_FILES['file']['tmp_name'], $targetfolder))
 
 {
 
 echo "The file ". basename( $_FILES['file']['name']). " is uploaded";
 
 }
 
 else {
 
 echo "Problem uploading file";
 
 }
 
}
 
else {
 
 echo "You may only upload PDFs<br>";
 
}
 
?>
 
Thanks,
Jeff Barnes

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: FiveWeb Questions

Postby Antonio Linares » Wed Feb 17, 2016 9:18 pm

great! :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: FiveWeb Questions

Postby Jeff Barnes » Thu Feb 18, 2016 5:09 pm

Using the following:

Code: Select all  Expand view

?'<form action="../upload.php" method="post" enctype="multipart/form-data" target="_blank","width=600,height=400">'
    ?'<input type="file" name="file" id="file">'
    ?'<input type="submit" value="Upload Report" name="submit">'
?'</form>'
 


The file name is placed in "file"

If I do the following I get what I expect to see.
Code: Select all  Expand view
MsgInfo(file.value)


But when I try to pass the value using the code below, nothing is passed.
Code: Select all  Expand view
'document.getElementById( "file" ).value.trim() '


Any ideas?
Thanks,
Jeff Barnes

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: FiveWeb Questions

Postby Enrico Maria Giordano » Thu Feb 18, 2016 5:52 pm

As I already said, you can't. It's a security measure.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: FiveWeb Questions

Postby Jeff Barnes » Thu Feb 18, 2016 6:17 pm

I'm not trying to "set" the file name, I'm trying to Get it.

MsgInfo(file.value) will return "C:\fakename\myfilename.pdf"
So If MsgInfo() can get the value why not 'document.getElementById( "file" ).value.trim() ' ?

I do not require the path so I can just pull out the myfilename.pdf from what is returned.
Thanks,
Jeff Barnes

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: FiveWeb Questions

Postby Enrico Maria Giordano » Thu Feb 18, 2016 7:18 pm

Sorry, I misunderstood your question. :-(

Ok, try to remove name="file".

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: FiveWeb Questions

Postby Jeff Barnes » Thu Feb 18, 2016 7:26 pm

"name=file" is what gets passed to upload.php
If I remove that I get errors in my upload.php file :(
Thanks,
Jeff Barnes

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: FiveWeb Questions

Postby Enrico Maria Giordano » Thu Feb 18, 2016 7:34 pm

So remove id="file" and use something like

Code: Select all  Expand view
$_POST[ "File" ]


(PHP)

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: FiveWeb Questions

Postby Jeff Barnes » Thu Feb 18, 2016 7:45 pm

Sorry Enrico but I'm not too familiar with php.
I added the $_POST["file"] to the php file but get an error in my php code now:

"Undefinded index: file" at the line where I added $_POST["file']

I'm still confused as to why MsgInfo() will show the correct info but I can't seem to get it any other way.
Thanks,
Jeff Barnes

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: FiveWeb Questions

Postby Jeff Barnes » Thu Feb 18, 2016 8:15 pm

I think I may have not stated clearly what it is I am after.

The php code is able to get the filename submitted via my button.
The file gets uploaded. All is good on this side.

What I want to do is take the filename and add it to a field in my dbf file.

If I click the Choose file button
Code: Select all  Expand view
?'<input type="file" name="file" id="file">'


Then with a button in my dialog do something like:
Code: Select all  Expand view
@ x,y button ..... ACTION MsgInfo(file.value)


It will return the filename (along with "C:\fakepath" which I am ok with).

So it's on the Fiveweb code side I need to get the filename from "file.value"

Again, If it can be done with MsgInfo() it should also work with:
Code: Select all  Expand view
'document.getElementById( "file" ).value.trim() '


This is where I am getting confused.

I hope that explains it clearly :oops:
Thanks,
Jeff Barnes

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: FiveWeb Questions

Postby Antonio Linares » Thu Feb 18, 2016 8:17 pm

Jeff,

So If MsgInfo() can get the value why not 'document.getElementById( "file" ).value.trim() ' ?


I think it is cause the quotes " inside the string

Those expressions get stringfied. Please check the source code of the resulting web page and see what javascript code is there
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: FiveWeb Questions

Postby Antonio Linares » Thu Feb 18, 2016 8:29 pm

ops, sorry, thats not the problem

Please try with:

... ACTION ... alert( document.getElementById( "file" ).value.trim() );
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: FiveWeb Questions

Postby Jeff Barnes » Thu Feb 18, 2016 8:34 pm

Last part of the button used to "save" all the fields:
document.getElementById( "oGet33" ).value.trim() + ":" + document.getElementById( "file" ).value.trim() } );

Line for the MsgInfo(file.value)
$( "#oBtn4" ).click( function( event ){ MsgInfo( file.value ) } );


I tried to remove the quotes from "file" but it did not help.
Thanks,
Jeff Barnes

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: FiveWeb Questions

Postby Jeff Barnes » Thu Feb 18, 2016 8:49 pm

... ACTION ... alert( document.getElementById( "file" ).value.trim() )

Does show "c:\fakename\filename.ext"

So since we can see it with both MsgInfo() and Alert(), how can I get the value into a DBF :?:
Thanks,
Jeff Barnes

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: FiveWeb Questions

Postby Antonio Linares » Thu Feb 18, 2016 8:55 pm

Jeff,

You have to supply that value to the FiveWeb cgi app as a parameter to save it

Have you tried it ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 63 guests