CodeIgniter Forums

Full Version: uploadify redirect after uploading all files
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

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)

function index($albumId) {
        if (!empty($_FILES)) {
            //$albumId = $this->uri->sement(2);
            $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;
            $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->_create_thumbs($fileName, $newName);
            unlink(APPPATH . "../images/uploads/tmp/" . $fileName);

thx for help Smile

El Forum

[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:

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

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