File Upload but store file on a different drive not working

File Upload but store file on a different drive not working

YoDavishYoDavish Posts: 123Questions: 46Answers: 3

Rather than storing the file on the "$_SERVER['[DOCUMENT_ROOT]']" like in the example found here:

https://editor.datatables.net/examples/advanced/upload.html

The $_SERVER['[DOCUMENT_ROOT] would point onto the C drive under the wwwroot folder. Instead, I wanted to use d drive to store the file location, but I'm unable to do this. It runs, but nothing is stored in the file location I gave it. Below is the code that the server side runs and where it should be stored. Is there something I'm missing?

    Field::inst('imageFile')
                ->setFormatter( Format::ifEmpty( null ) )
                ->upload( Upload::inst( '**D:/temp**/__ID__.__EXTN__' )
                        ->db( 'propath_dev.tempfile', 'id', array(
                            'fileName'    => Upload::DB_FILE_NAME,
                            'fileSize'    => Upload::DB_FILE_SIZE,
                            'webPath'    => Upload::DB_WEB_PATH,
                            'systemPath' => Upload::DB_SYSTEM_PATH
                        ) )
                        ->validator( Validate::fileSize( 500000, 'Files must be smaller that 500K' ) )
                        ->validator( Validate::fileExtensions( array( 'pdf' ), "Please upload an PDF" ) )
                )

This question has an accepted answers - jump to answer

Answers

  • YoDavishYoDavish Posts: 123Questions: 46Answers: 3
    Answer ✓

    Resolved it, if I declare the variable on the page, then it works

        $fileLocation= 'D:\temp';
    
        upload( Upload::inst( $fileLocation.'/__ID__.__EXTN__' )
    
  • colincolin Posts: 15,237Questions: 1Answers: 2,598

    Excellent, glad all sorted,

    Colin

This discussion has been closed.