Welcome Guest, Not a member yet? Register   Sign In
uploadify redirect after uploading all files
#1

[eluser]jacobson[/eluser]
Hello, I have a problem with upladify. I managed to make it work properly. My question is how to check in my php code whether the uploading of all files is finished in order to redirect page (refresh to show the uploaded images)

Code:
function index($albumId) {
        if (!empty($_FILES)) {
            //$albumId = $this->uri->sement(2);
            $this->load->library('image_lib');
            
            $tempFile = $_FILES['Filedata']['tmp_name'];
            $targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';
            $targetFile = str_replace('//', '/', $targetPath) . $_FILES['Filedata']['name'];
            $fileName = $_FILES["Filedata"]["name"];

            move_uploaded_file($tempFile, $targetFile);
            
            echo str_replace($_SERVER['DOCUMENT_ROOT'], '', $targetFile);
            $maxId = 0;
            $q = $this->db->select('MAX(name) as maxid')->get('images');
            foreach($q->result() as $item)
                $maxId = $item->maxid;
          
            $maxId++;
            $newName = $maxId.'.jpg';
            
            $data = array(
                'albumId' => $this->uri->segment(3),
                'name' => $newName
            );

            $this->db->insert('images', $data);
            
            $config = array(
                'source_image' => APPPATH . '../images/uploads/tmp/' . $fileName,
                'new_image' => APPPATH . '../images/uploads/'. $newName,
                'maintain_ration' => TRUE,
                'width' => 500,
                'height' => 400
            );

            $this->image_lib->initialize($config);
            $this->image_lib->resize();
            $this->_create_thumbs($fileName, $newName);
            
            
            unlink(APPPATH . "../images/uploads/tmp/" . $fileName);
        }
    }

thx for help Smile
#2

[eluser]Rok Biderman[/eluser]
There is no way to check for uploading of all files from serverside as each file gets requested separately and the server has no way of knowing how many there are.

If you think about it for a second, it actually makes sense. As the client is the one who is taking the action (pushing all the files to the server), it's only normal that he would know and handle when he is done and request a refresh. In Uploadify this is easily done like this:

Code:
'onQueueComplete' : function() { [removed].href=[removed].href }

Note: change the [removed] into window, cause the security features on the forums stripped it.




Theme © iAndrew 2016 - Forum software by © MyBB