我有一个PHP脚本,它接收一个上传,并通过shell_exec()将该上传的处理推迟到后台脚本。
但是后台脚本似乎无法访问上传的临时文件。
接收方脚本
$file_loc = $_FILES['file']['tmp_name'];
echo $file_loc.' exists = '.file_exists($file_loc);
shell_exec('php background.php -i='.$file_loc.' >report.txt &');这输出
{路径到文件}存在=1
Background.php
$args = getopt('i:');
$file_loc = $args['i'];
echo $file_loc.' exists = '.file_exists($file_loc);在result.txt我得到
{路径到文件}存在=
也就是不存在。我需要做什么才能允许后台脚本访问tmp文件位置?
发布于 2018-11-12 13:40:16
您应该将上传的文件移动到一个新的目标来处理该文件。
$destination = "FOLDER_NAME/".$_FILES['file']['tmp_name'];
$file_loc = $_FILES['file']['tmp_name'];
move_uploaded_file ( $file_loc, $destination )
echo $destination.' exists = '.file_exists($destination);
shell_exec('php background.php -i='.$destination.' >report.txt &');https://stackoverflow.com/questions/53262688
复制相似问题