header("location: /files/box/stage/"."$nameandext"); // send copy to browser
header function will just send header information to browser, it is not sending complete file to browser.
Try to use the below code, surely it will work and i have tested it.
header('Content-type: text/plain'); // change this content type based on your file extension
header('Content-Disposition: attachment; filename="'.$nameandext.'"');
readfile($nameandext);
ob_end_flush();
unlink($nameandext);
well getting pretty close. Tamil’s suggested code below working EXCEPT no image presented. just an empty box of proper size with the little X in the corner…
header(‘Content-type: image/jpeg’); // change this content type based on your file ext
header(‘Content-Disposition: inline; filename="’.$newpath.$nameandext.‘"’);
readfile($newpath.$nameandext);
ob_end_flush();
unlink($newpath.$nameandext);
now I’m going in circles. the problem above is why I switched from non-working readfile(), fopen(), fpassthru(), to the WORKING header(location) redirect !!!
why is that image getting lost???
OR is there some way to force completion of header(location) redirect, then unlink the same file ???
any thoughts at all PLEASE !!