Setting the location of a temporary folder

I am working on linux. I made some progresses with search and
highlight app and have a little problem.

I have a script called run.php. What it does is get a pdf file and
highlight the search query by invoking the java code I work on.

if I run command prompt - php run.php, it will works.

But If I do - php app/run.php
It will complain:

     Message: mkstemp() failed to create a temporary file.
    at pdftron.PDF.ElementWriter.End(Native Method)
    at pdftron.PDF.ElementWriter.end(
    at PDFSearch.CreateHighlightAppearance(
    at PDFSearch.CreateHighlightAnnot(
    at PDFSearch.main(
Exception in thread "main" java.lang.NullPointerException
    at pdftron.PDF.Annot.setAppearance(
    at PDFSearch.CreateHighlightAnnot(
    at PDFSearch.main(

That is because it cannot create temporary files to the directory,
where the current php command execute. i.e. app/

If I set 777 to app/, it will work well, but I will not do it.

I wonder is there any solution to this problem. e.g. only write
temporary file to under app/
A: You can use PDFNet::SetTempPath(" path..") to set the location
of temporary folder to an arbitrary location.