Page 4 of 10
Re: FiveWeb Questions
Posted: Wed Feb 17, 2016 7:58 pm
by Jeff Barnes
I have the file uploading working ...
Inside dialog setup:
Code: Select all | Expand
?'<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
<?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>";
}
?>
Re: FiveWeb Questions
Posted: Wed Feb 17, 2016 9:18 pm
by Antonio Linares
great!

Re: FiveWeb Questions
Posted: Thu Feb 18, 2016 5:09 pm
by Jeff Barnes
Using the following:
Code: Select all | Expand
?'<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.
But when I try to pass the value using the code below, nothing is passed.
Any ideas?
Re: FiveWeb Questions
Posted: Thu Feb 18, 2016 5:52 pm
by Enrico Maria Giordano
As I already said, you can't. It's a security measure.
EMG
Re: FiveWeb Questions
Posted: Thu Feb 18, 2016 6:17 pm
by Jeff Barnes
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.
Re: FiveWeb Questions
Posted: Thu Feb 18, 2016 7:18 pm
by Enrico Maria Giordano
Sorry, I misunderstood your question.

Ok, try to remove name="file".
EMG
Re: FiveWeb Questions
Posted: Thu Feb 18, 2016 7:26 pm
by Jeff Barnes
"name=file" is what gets passed to upload.php
If I remove that I get errors in my upload.php file

Re: FiveWeb Questions
Posted: Thu Feb 18, 2016 7:34 pm
by Enrico Maria Giordano
So remove id="file" and use something like
(PHP)
EMG
Re: FiveWeb Questions
Posted: Thu Feb 18, 2016 7:45 pm
by Jeff Barnes
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.
Re: FiveWeb Questions
Posted: Thu Feb 18, 2016 8:15 pm
by Jeff Barnes
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
Then with a button in my dialog do something like:
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:
This is where I am getting confused.
I hope that explains it clearly

Re: FiveWeb Questions
Posted: Thu Feb 18, 2016 8:17 pm
by Antonio Linares
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
Re: FiveWeb Questions
Posted: Thu Feb 18, 2016 8:29 pm
by Antonio Linares
ops, sorry, thats not the problem
Please try with:
... ACTION ... alert( document.getElementById( "file" ).value.trim() );
Re: FiveWeb Questions
Posted: Thu Feb 18, 2016 8:34 pm
by Jeff Barnes
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.
Re: FiveWeb Questions
Posted: Thu Feb 18, 2016 8:49 pm
by Jeff Barnes
... 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

Re: FiveWeb Questions
Posted: Thu Feb 18, 2016 8:55 pm
by Antonio Linares
Jeff,
You have to supply that value to the FiveWeb cgi app as a parameter to save it
Have you tried it ?