Announcement

Collapse
No announcement yet.

file upload

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • file upload

    I run an upload a pdf file, changing the field with document file name, the file is placed in the tmp folder, but does not have the correct name, such as the file and 'hotspot.pdf, after I find myself sc_37492da9_hotspot.pdf as I can solve

  • #2
    You do not need to solve that. The file in the tmp folder will be moved to your chosen directory the moment when the records are saved. And they will also be properly be renamed (without the sc_...._ part that is).

    Comment


    • #3
      but explain any script, how save file and without the sc_

      Comment


      • #4
        I think what rr is saying is that whilst editing the record the uploaded file isn't yet put into the correct folder as it first uploads to a temporary directory on your server. So basically once you update/save/insert the record you should have no problem downloading it as by then it should've put it into the correct folder.

        Comment


        • #5
          i use field for upload, but file is saved in tmp dir and is ok for me, but want the name of file without sc_ , because i use script for send mail:

          sc_mail_send('xxx', 'xxx', 'xxxx', 'xxxxx', [email], 'demo-hotel', $testo, 'H', 'xxxxxx', 'H', '', '','/var/www/vhosts/xxxxxxx/httpdocs/scriptcase/tmp/fattura-demo.pdf', );

          if possible change name with variable ?
          Attached Files

          Comment


          • #6
            Aha now I got your point. So you want a TEMPORARY file upload. And the moment when clicks mail you want the file removed. So doing an sc_redir would not save the record. Yet the file will still be in the tmp dir tho...
            You'd have to call an sc_rollback_trans and work with transactions (sc_begin_trans and sc_rollback_trans) if you do it properly.
            Anyway your temporary file can be found in your code if you investigate the generated code.
            The temporary filename can be retrieved exactly BUT it depends on the name of your project and the way you made your application. Since this is not the standard way you'd have to use things like:
            So in order to find your temporary name do the following:
            On the OnValidate place some code that catches your filename (assuming your field is called FILENAME e.g.:
            echo 'Filename='.{FILENAME}.'<br>';
            Then you'll see the temporary filename (at least that is how I found it way back in the scriptcase V6 and V7 versions, it is likely still working that way).
            I kinda recall that you simply could use $this->filename but I dont recall it exactly anymore. You can simply test it tho just echo that in your OnValidate and you'll see.
            In fact you can echo the whole $this value in detail and you'll find amazingly interesting values that you can use.
            Be aware this is more advanced stuff.

            Comment


            • #7
              i try in On the OnValidate ,echo 'Filename='.{FILENAME}.'<br>'; and i see hotspot.pdf, but in my tmp dir is : sc_bc7eddb0_hotspot.pdf, not solve my issue , i want if possible the name is hotspot.pdf

              Comment


              • #8
                Oh well that is super easy, just cut of the first sc_bc7eddb0_ bit which is always 12 characters.
                Anyway if you would have used print_r($this) you would have seen something like this (in my example!! find the bolded piece in de code block)
                Code:
                form_SCRIPTCASE_SC_UPLOAD_form Object ( [has_where_params] => [NM_is_redirected] => [NM_non_ajax_info] => [NM_ajax_flag] => 1 [NM_ajax_opcao] => submit_form [NM_ajax_retorno] => [NM_ajax_info] => Array ( [result] => [param] => Array ( [filename_] => [lastupdate_] => [filename__ul_name] => sc_ce321088_rec.ini [filename__ul_type] => application/octet-stream [filename__salva] => [filename__limpa] => N [nmgp_refresh_row] => 1 [nm_form_submit] => 1 [nmgp_url_saida] => [nmgp_opcao] => incluir [nmgp_ancora] => [nmgp_num_form] => [nmgp_parms] => Sc_num_lin_alt?#?1?@? [script_case_init] => 1551 [buffer_output] => 1 ) [autoComp] => [rsSize] => [msgDisplay] => [errList] => Array ( ) [fldList] => Array ( ) [focus] => [navStatus] => Array ( ) [navSummary] => Array ( ) [navPage] => Array ( ) [redir] => Array ( ) [blockDisplay] => Array ( ) [fieldDisplay] => Array ( ) [fieldLabel] => Array ( ) [readOnly] => Array ( ) [btnVars] => Array ( ) [ajaxAlert] => [ajaxMessage] => [ajaxJavascript] => Array ( ) [buttonDisplay] => Array ( ) [calendarReload] => ....
                So simply use a print_r($this) or a print_r($this->filename__ul_name) in your OnValidate event and you will see what I mean.
                That filename is the name of the file you wanted.

                Comment

                Working...
                X