I use jQuery-File-Upload when uploading files, create a folder on the server and upload it there.

$folder = date("dmY His"); // присваиваем переменно сег. дату $up = '/image/'.$folder.'/'; //$title = '/4ddddd/'; $this->response = array(); $this->options = array( 'script_url' => $this->get_full_url().'/'.$this->basename($this->get_server_var('SCRIPT_NAME')), 'upload_dir' => dirname($this->get_server_var('SCRIPT_FILENAME')).$up, 'upload_url' => $this->get_full_url().$up, 

The $up variable needs to extend the life while the user is on the site ... I think in $_SESSION I don’t know how to implement it ....

  • Do you have users logged in?) If yes, then where you store user authorization data in the same place you can store data about the name of the folder. For example, the same cookies if you want, well, or if you want something in a session to write $_SESSION['name'] = "value"; - Moonvvell
  • Not logged in as ... - Erik Galin

1 answer 1

To make

 <?php session_start(); // Точку с запятой добавил 

at the beginning of the script .

Further in this block:

 $folder = date("dmY His"); // присваиваем переменно сег. дату // Начало изменённого кода if(!isset($_SESSION['up'])){ $_SESSION['up'] = '/image/'.$folder.'/'; } $up = $_SESSION['up']; // Конец изменённого кода //$title = '/4ddddd/'; $this->response = array(); $this->options = array( 'script_url' => $this->get_full_url().'/'.$this->basename($this->get_server_var('SCRIPT_NAME')), 'upload_dir' => dirname($this->get_server_var('SCRIPT_FILENAME')).$up, 'upload_url' => $this->get_full_url().$up, 
  • Let's try - Eric Galin
  • session_start () where to put? Php code here - Eric Galin
  • @EricGalin, and isn't session_start() a php function, that you can't put it in php code? - Visman Sep.
  • one
    session_start () must go before any data is sent to the client. - Arnial
  • one
    @EricGalin, the file encoding must be UTF-8 without BOM. - Visman September