I hate bugs
On further analysis:
On the filename there is the javascript:nmmostra_doc(‘0’,‘wmovies2_1024.jpg’,;form_SCRIPTCASE_TST_FILEUPLOAD’) call.
This results in a window that opens with form_SCRIPTCASE_TST_FILEUPLOAD_doc.php with a number of parameters.
http://…/form_SCRIPTCASE_TST_FILEUPLOAD/form_SCRIPTCASE_TST_FILEUPLOAD_doc.php?script_case_init=444&script_case_session=1p50msi3jhmb2nn6untognp3f1&nm_cod_doc=0&nm_nome_doc=wmovies2_1024.jpg&nm_cod_apl=form_SCRIPTCASE_TST_FILEUPLOAD
The parameters become variables in the routine as far as I can see.
The php code of the generated php file:
<?php
session_cache_limiter("");
session_start();
include_once 'form_SCRIPTCASE_TST_FILEUPLOAD_nmutf8.php';
if (!empty($_GET))
{
foreach ($_GET as $nmgp_var => $nmgp_val)
{
$$nmgp_var = NM_utf8_decode(NM_utf8_urldecode($nmgp_val));
}
}
if ($nm_cod_doc == "documento_db")
{
$NM_dir_atual = getcwd();
if (empty($NM_dir_atual))
{
$str_path_sys = (isset($_SERVER['PATH_TRANSLATED'])) ? $_SERVER['PATH_TRANSLATED'] : $_SERVER['SCRIPT_FILENAME'];
$str_path_sys = str_replace("\\", '/', $str_path_sys);
$str_path_sys = str_replace('//', '/', $str_path_sys);
}
else
{
$sc_nm_arquivo = explode("/", $_SERVER['PHP_SELF']);
$str_path_sys = str_replace("\\", "/", str_replace("\\\\", "\\", getcwd())) . "/" . $sc_nm_arquivo[count($sc_nm_arquivo)-1];
}
$str_path_web = $_SERVER['PHP_SELF'];
$str_path_web = str_replace("\\", '/', $str_path_web);
$str_path_web = str_replace('//', '/', $str_path_web);
$root = substr($str_path_sys, 0, -1 * strlen($str_path_web));
$trab_doc = $root . $_SESSION['scriptcase']['form_SCRIPTCASE_TST_FILEUPLOAD']['glo_nm_path_imag_temp'] . "/sc_" . $nm_nome_doc;
}
else
{
$path_raiz = $_SESSION['sc_session'][$script_case_init][$nm_cod_apl]['path_doc']; <<<<<<<<<here is where I apparently go with the code
$sub_path = $_SESSION['sc_session'][$script_case_init][$nm_cod_apl]['sub_dir'][$nm_cod_doc];
$trab_doc = $path_raiz . $sub_path . "/" . $nm_nome_doc; <<<<<<< thus the path is coming from the document path of the application with the subdir (none for me) added followed by a slash and the filename. Then any \\ is converted to / as well as \\ converted to / for making the correct path.
$trab_doc = str_replace("\\", "/", $trab_doc);
$trab_doc = str_replace("//", "/", $trab_doc);
//ADD THIS LINE TO FIND OUT THE PATH
echo "Doc file path:" . $trab_doc . "<br>";
}
if (is_file($trab_doc)) <<<<apparently the error is here... :(
{
header("Content-type: application/force-download");
header("Content-Disposition: attachment; filename=\"" . urlencode($nm_nome_doc) . "\" filename*=UTF-8''" . urlencode($nm_nome_doc));
readfile($trab_doc);
}
else
{
$STR_lang = (isset($_SESSION['scriptcase']['str_lang']) && !empty($_SESSION['scriptcase']['str_lang'])) ? $_SESSION['scriptcase']['str_lang'] : "en_us";
$NM_arq_lang = "../_lib/lang/" . $STR_lang . ".lang.php";
if (is_file($NM_arq_lang) && $STR_lang != "en_us")
{
$Lixo = file($NM_arq_lang);
foreach ($Lixo as $Cada_lin)
{
$Tst = explode("=", $Cada_lin);
if (strpos($Tst[0], "lang_errm_fnfd") !== false)
{
$Nm_lang['lang_errm_fnfd'] = substr(trim($Tst[1]), 1, -2);
}
}
}
else
{
$Nm_lang['lang_errm_fnfd'] = "The file does not exist";
}
echo $Nm_lang['lang_errm_fnfd'] . ": " . $nm_nome_doc;
}
exit;
?>
So now my result is:
Doc file path:/scriptcase/app/TestConnection2/files/wmovies2_1024.jpg
The file does not exist: wmovies2_1024.jpg
The odd thing: the path seems correct and the file is absolutely there…
The proof is in the fact that if it is an image file path that it does work…
So please fix this as asap…
Apparently the is_file is delivering false according to echo “is_file:”.var_dump(is_file($trab_doc))."<br>";
even tho the path is correct… Very very odd…