This topic is locked
[SOLVED]

 Basic File Upload change

1/20/2020 12:28:22 PM
PHPRunner General questions
S
sts098 author

I am attempting to switch from Basic File Upload control. File type is medium text. Using phprunner 10.2
I am uploading pdf files. When using Basic File upload control, I would set:

Edit as - File Image

view as - Hyperlink
This allowed me to have the pdf open in another window.
From list view, Old links (those entered with Basic upload checkbox clicked) still work. Below is a link (you will not be able to reach as it is an internal url)
http://10.100.0.23/phprunner/equipment/files/quotes/UGL%20-%20AMS%20%20Q01253.pdf
In list view New files entered (Basic Checkbox unchecked) produce the link:
http://10.100.0.23/phprunner/equipment/files/quotes/[%7B%22name%22:%22files//quotes//Quotation%20-%200107-20-0104%20for%20UGL_j0z757dd.pdf%22,%22usrName%22:%22Quotation%20-%200107-20-0104%20for%20UGL.pdf%22,%22size%22:188274,%22type%22:%22application//pdf%22,%22searchStr%22:%22Quotation%20-%200107-20-0104%20for%20UGL.pdf,!:sStrEnd%22%7D]?rndVal=0.9423444604541011
Clicking on this produces error 404 File Not Found
Changing View as: to File. Works for both old field entered as Basic and new fields basic unchecked. And produces link below:
http://10.100.0.23/phprunner/equipment/mfhandler.php?file=UGL%20-%20AMS%20%20Q01253.pdf&table=revision&field=file&pageType=list&key1=1194
BUT the file is downloaded not opened.
Is there any way to have the pdfs (entered both basic and not) open in a new window.

S
sts098 author 1/20/2020



I am attempting to switch from Basic File Upload control. File type is medium text. Using phprunner 10.2
I am uploading pdf files. When using Basic File upload control, I would set:

Edit as - File Image

view as - Hyperlink
This allowed me to have the pdf open in another window.
From list view, Old links (those entered with Basic upload checkbox clicked) still work. Below is a link (you will not be able to reach as it is an internal url)
http://10.100.0.23/phprunner/equipment/files/quotes/UGL%20-%20AMS%20%20Q01253.pdf
In list view New files entered (Basic Checkbox unchecked) produce the link:
http://10.100.0.23/phprunner/equipment/files/quotes/[%7B%22name%22:%22files//quotes//Quotation%20-%200107-20-0104%20for%20UGL_j0z757dd.pdf%22,%22usrName%22:%22Quotation%20-%200107-20-0104%20for%20UGL.pdf%22,%22size%22:188274,%22type%22:%22application//pdf%22,%22searchStr%22:%22Quotation%20-%200107-20-0104%20for%20UGL.pdf,!:sStrEnd%22%7D]?rndVal=0.9423444604541011
Clicking on this produces error 404 File Not Found
Changing View as: to File. Works for both old field entered as Basic and new fields basic unchecked. And produces link below:
http://10.100.0.23/phprunner/equipment/mfhandler.php?file=UGL%20-%20AMS%20%20Q01253.pdf&table=revision&field=file&pageType=list&key1=1194
BUT the file is downloaded not opened.
Is there any way to have the pdfs (entered both basic and not) open in a new window.


Found the blog post
October 21, 2015

Adding PDF preview support to your web application
Having issues getting it to work with my files that are not located in the root directory. Blog has an unanswered comment indicating issue is not just me.

S
sts098 author 1/20/2020

Answer to my own questions
Nothing to do with directory. The code assumed the key field was ID. needed to put the correct key field in. Also, Modified the code to work with both Basic and multifile input. The code takes three inputs - Your table, file field, key field.
$arrfile = my_json_decode($value);

$ext=strtoupper(substr($value,strlen($value)-4));
$mftable = "Your table";

$mfield = "Your file field";

$mkeyfld = "Your Key filed";
if($ext == ".PDF")

$value="<a target='_blank' href='ViewerJS/#../mfhandler.php?file=".$value."&table=".$mftable."&field=".$mfield."&pageType=list&key1=".$data[$mkeyfld]."'>".$value."</a>";

else{

$value="";

for($i=0;$i < count($arrfile);$i++){

if($value)

$value.=", ";

if($arrfile[$i]["type"] == "application/pdf")

$value.="<a target='_blank' href='ViewerJS/#../mfhandler.php?file=".$arrfile[$i]["usrName"]."&table=".$mftable."&field=".$mfield."&pagetype=list&key1=".$data[$mkeyfld]."'>".$arrfile[$i]["usrName"]."</a>";

else

$value.="<a href='mfhandler.php?file=".$arrfile[$i]["usrName"]."&table=".$mftable."&field=".$mfield."&pagetype=list&key1=".$data[$mkeyfld]."' dir='LTR'>".$arrfile[$i]["usrName"]."</a>";

}

}