FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour FiveWeb Questions
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Re: FiveWeb Questions
Posted: Wed Feb 17, 2016 07:58 PM
I have the file uploading working ...

Inside dialog setup:
Code (fw): Select all Collapse
?'<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 (fw): Select all Collapse
<?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)
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: FiveWeb Questions
Posted: Wed Feb 17, 2016 09:18 PM

great! :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Re: FiveWeb Questions
Posted: Thu Feb 18, 2016 05:09 PM
Using the following:

Code (fw): Select all Collapse
?'<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 (fw): Select all Collapse
MsgInfo(file.value)


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


Any ideas?
Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: FiveWeb Questions
Posted: Thu Feb 18, 2016 05:52 PM

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

EMG

Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Re: FiveWeb Questions
Posted: Thu Feb 18, 2016 06: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)
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: FiveWeb Questions
Posted: Thu Feb 18, 2016 07:18 PM

Sorry, I misunderstood your question. :-(

Ok, try to remove name="file".

EMG

Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Re: FiveWeb Questions
Posted: Thu Feb 18, 2016 07: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)
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: FiveWeb Questions
Posted: Thu Feb 18, 2016 07:34 PM
So remove id="file" and use something like

Code (fw): Select all Collapse
$_POST[ "File" ]


(PHP)

EMG
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Re: FiveWeb Questions
Posted: Thu Feb 18, 2016 07: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)
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Re: FiveWeb Questions
Posted: Thu Feb 18, 2016 08: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 (fw): Select all Collapse
?'<input type="file" name="file" id="file">'


Then with a button in my dialog do something like:
Code (fw): Select all Collapse
@ 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 (fw): Select all Collapse
'document.getElementById( "file" ).value.trim() '


This is where I am getting confused.

I hope that explains it clearly :-)
Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: FiveWeb Questions
Posted: Thu Feb 18, 2016 08: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
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: FiveWeb Questions
Posted: Thu Feb 18, 2016 08: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
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Re: FiveWeb Questions
Posted: Thu Feb 18, 2016 08: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)
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Re: FiveWeb Questions
Posted: Thu Feb 18, 2016 08: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)
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: FiveWeb Questions
Posted: Thu Feb 18, 2016 08: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