Welcome Guest, Not a member yet? Register   Sign In
Problem to Upload on a FTP using SWFUpload
#1

[eluser]Unknown[/eluser]
Hello,

In my application I want to integrate SWFUpload to let the users Upload files on a FTP server.

In fact, I want to do the same thing that The SimpleDemo on the SWFUpload site.

In my code I have successfully integrated the SWFUpload library and it works correctly for my little uploads. The problem happens when I try to upload files which have approximately a size bigger than 5 MB.

The problem is that my progressbar reach immediately 100%, and, only after that the upload process begins. An other problem that I have is that while a file is transferring I can't cancel and remove the upload.

From where come this problem ?

Here is my view code :

Code:
<form id="form1" action="<?php echo base_url();?/upload/do_upload" method="post" enctype="multipart/form-data">
            <fieldset class="flash" id="fsUploadProgress">
                <legend>Files to download</legend>
            </fieldset>
            <div id="divStatus">0 files uploaded</div>
            <p>
                &lt;input type="button" value="Select files"&gt;
                &lt;input id="btnCancel" type="button" value="Cancel queue"&gt;
            </p>
            &lt;?php echo form_close(); ?&gt;


Here is my controller. I mean the problem comes from the $_FILES variables, but I'm not sure.
Code:
public function do_upload($id_ftp, $id_folder)
    {
            ...
            ...
            ...
            
            //We retrieve the file to upload
            $file_tmp_path = $_FILES['Filedata']['tmp_name'];
            $file_name = $_FILES['Filedata']['name'];
            $file_type = $_FILES['Filedata']['type'];

            
            //Establish a ftp connection
            $conn = ftp_connect($ftp_host);
            //Error
            if(!$conn)
            {
                log_message('error', "Connexion error message");
            }
            else
            {
                //Identification
                ftp_login($conn, $ftp_user, $ftp_password);
                
                //Upload
                $ret = ftp_nb_put($conn, $ftp_path, $file_tmp_path, FTP_BINARY);    
                
                while($ret == FTP_MOREDATA)
                {                
                    //upload continues
                    $ret = ftp_nb_continue($conn);
                    echo $ret;    
                    ob_flush();
                    flush();
                }
                //upload ended
                echo $ret;
                ob_flush();
                flush();
                
                //Download error
                if ($ret != FTP_FINISHED)
                {
                    log_message("error", "download error message.");
                }
                else
                {
                    //Download OK

                }
                
                //FTP connection close
                if(!ftp_close($conn))
                {
                    log_message('error', "FTP close connection failed.");
                }
            }
        }
    }

Can the problem happen because I want to upload my files on a FTP server ?




Theme © iAndrew 2016 - Forum software by © MyBB