Get temporary file name with complete path

Hai everyone,
I am developing an application where I have to get the uploaded document name with path with following scenario:

field name : document_upload_path field Type Document (File Name)
After going through many forum topics I could get it working. So the credit of the solution (if it right) goes to all the members of the forum who contributed to this temporary path / file
I am using a variable to get the path with the name of the file uploaded into variable $temp_fileName.
Following is the statement for the getting the file name with path
$temp_fileName = $this->Ini->root . $this->Ini->path_imag_temp ."/" .$this->document_upload_path_ul_name;
Note : Files uploaded are first stored in a temporary directory which is fixed in Scriptcase development environment configuration when deploying.
The files are given actual name and moved to designated storage when Saved / Inserted
I am sharing based on my personal trials. I can be wrong and request other members to post any corrections.

1 Like

Hi, what version of sc do you use? :thinking:
I need to do something similar to your example, but the code you explain only returns the directory, not the file name. :expressionless:
I can’t find a way to get the full path plus the file name, I have to enter data from an excel file to a database. :pensive:

hi @dgonzalez
I am using the latest version of SC 9.xx
Can you share your code in whatever event you are using?
Is the directory returned correct ? Does it contain the uploaded file ? Note, my above code example is at a point of the code execution as follows

  1. The Form application is run
  2. Use clicks on the field and uploads a file
  3. Before hitting the Save / Add button , I want to check the uploaded file for validation. At this point the uploaded file is in a temporary directory, details of which can be found under Settings of the Dev. Environment and under the specified at deployment
    3a. That is why on Validate Event I get the file and check the same. If everything ok I do not report any error
  4. User presses Save and the file is moved to the programmer/user specified folder

Following is what I have done
$temp_fileName = $this->Ini->root . $this->Ini->path_imag_temp ."/" .$this->document_upload_path_ul_name; //document_upload_path_ul_name; here document_upload_path is the field name which allows the upload of document The field type is Document (FileName)
I think SC automatically attaches the ul_name in the code behind when it generates the code.
So if your upload field is dgonzalez_upload_field it might make it as dgonzalez_upload_field_ul_name.
You can test this and let me know

Hope this helps. IF I am wrong, please correct it as it help others and me too

1 Like

Hi @sriraminfotec.

I am using version 9 of sc.
The way I try to read the file name is as follows:

  1. I have a control application with file type inputs.
  2. In the onValidateSuccess event of the control application, I store the path of the file in a variable, following your example:
    {location}=$this->Ini->root . $this->Ini->path_imag_temp."/".$this->fileone_path_ul_name;
    But this doesn’t return the full path, the result is something like this: /var/www/html/scriptcase/tmp/
    What I notice is that if I use:
    {location}=$this->Ini->root . $this->Ini->path_imag_temp."/".{fileone};
    The result returns the full path:
    /var/www/html/scriptcase/tmp/DATEST(56).xlsx
  3. I try to pass this path through a link to a blank application, to process it with a kde excel library.
  4. When the sc data arrives, it tells me that it cannot find the file.

Among other tests that I do, note that when uploading a file, a request is executed via post "control_php_excel_ul_save.php " , its response returns the document data and it shows me the name of the file concatenated with a code for example:
…/scriptcase/tmp/sc_db1f986a_DATEST.xlsx, same file but name changed. Put the returned name to send it to the blank application and it worked.
Unfortunately I still do not get a way to pass the name of the file to be processed.
Thank you very much for your support . :smiley:

First of all thanks for being kind enough to update your result.
In my came i am using the Field Type as “Document (Image Name)” and this is in the FORM Application
You are using a control application. Probably some thing changes here. I will try and check out in a couple of days.
The issue with Scriptcase is that it lacks proper documentation and the information appears scattered across these forums, youtube videos and the official documentation of scriptcase.
I am still learning , 3 years into scriptcase. Supposed to be good RAD tool but quite daunting.
The developers have thought of most aspects when developing the Tool, but not much when developing the documentation
That is why I keep sharing some info I learn from my experience here in this forum.
Hope scriptcase comes with a program to involve a few developers to develop a good documentation.
Thanks once again.

problem is their developer don’t answer the forum.