Welcome Guest, Not a member yet? Register   Sign In
SWF Uploader - help required
#1

[eluser]Computerzworld[/eluser]
Hello,
I am trying to implement jquery swf uploader in CI. But its not working. Is there any modifications that I have to do in order to make it work? Or any other alternative solution that can be integrated? Please help me. Thanks in advance.
#2

[eluser]Clooner[/eluser]
Could you give some more detailed information?
Are you using a swf uploader or a jquery(ajax) ? For the some of the ways using ajax you need special modules installed on your webserver.
#3

[eluser]Computerzworld[/eluser]
I am using jquery uploader from this website. If I run it separately then its working fine. But if I integrate it in CI then it doesn't work. Is there any modifications required in order to make it run?

Here is my view file.

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
&lt;html lang="en"&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;title&gt;jqUploader demo&lt;/title&gt;
&lt;link rel="stylesheet" type="text/css" media="screen" href="style.css"/&gt;
[removed][removed]
[removed][removed]
[removed][removed]
[removed]
$(document).ready(function(){
    $('#example1').jqUploader({background:'FFFFDF',barColor:'FFDD00',allowedExt:'*.avi; *.jpg; *.jpeg; *.png;',allowedExtDescr: 'what you want',validFileMessage: 'Thanks, now hit Upload!',endMessage: 'and don\'t you come back ;)',hideSubmit: false});
    $("#example2").jqUploader({
        afterScript:    "redirected.php",
        background:    "FFFFDF",
        barColor:    "64A9F6",
        allowedExt:     "*.avi; *.jpg; *.jpeg; *.png",
        allowedExtDescr: "Images and movies (*.avi; *.jpg; *.jpeg; *.png)"
    });

    $("#example3").jqUploader({background:    "FFFFDF",barColor:    "FF00FF"});
});
[removed]
&lt;/head&gt;
&lt;body&gt;
  &lt;form enctype="multipart/form-data" action="flash_upload.php" method="POST" class="a_form"&gt;
    <fieldset>
    <legend>Your picture</legend>
    <ol>
      <li id="example1">
        <label for="example1_field">Choose a file to upload: </label>
        &lt;input name="MAX_FILE_SIZE" value="1048576" type="hidden" /&gt;
        &lt;input name="myFile"  id="example1_field"  type="file" /&gt;
      </li>
    </ol>
    </fieldset>
    &lt;input type="submit" name="submit" value="Send" /&gt;
  &lt;/form&gt;
  &lt;form enctype="multipart/form-data" action="flash_upload.php" method="POST" class="a_form"&gt;
    <fieldset>
    <legend>Upload your file</legend>
    <ol>
      <li id="example2">
        <label for="example2_field">Choose a file to upload:</label>
        &lt;input name="myFile2" id="example2_field"  type="file" /&gt;
      </li>
    </ol>
    </fieldset>
    &lt;input type="submit"  name="submit" value="Upload File" /&gt;
  &lt;/form&gt;
  &lt;form enctype="multipart/form-data" action="flash_upload.php" method="POST" class="a_form"&gt;
    <fieldset>
    <legend>Upload your file</legend>
    <ol>
      <li id="example3">
        <label for="example3_field">Choose a file to upload:</label>
        &lt;input name="myFile3" id="example3_field"  type="file" /&gt;
      </li>
    </ol>
    </fieldset>
    &lt;input type="submit" name="submit" value="Upload File" /&gt;
  &lt;/form&gt;
</div>
&lt;/body&gt;
&lt;/html&gt;
&lt;?php
//define("_BBC_PAGE_NAME", "jqUploader Index");
define("_BBCLONE_DIR", $localpath ."stats/");
define("COUNTER", _BBCLONE_DIR . "mark_page.php");
if (is_readable(COUNTER)) include_once(COUNTER);
?&gt;

Thanks.
#4

[eluser]Clooner[/eluser]
What exactly happens? Is the html input dialog replaced by the swf or not? Doesn't it upload but shows the dialog? Or doesn't it show the success message?
#5

[eluser]Computerzworld[/eluser]
it shows swf but not file upload field.... so i am not able to browse & upload the filesSad
#6

[eluser]Clooner[/eluser]
Sounds like the javascript is not correctly replacing the input box with the flash box. Any javascript errors? Are the paths to all the files correct?
#7

[eluser]Computerzworld[/eluser]
yes all files path are correct & it is replacing input box with flashbox. I have checked it by right click and it displayed me as flash content. But the upload field doesn't comes...
#8

[eluser]Computerzworld[/eluser]
Now I am using swfupload for upload progress bar. But when I tried to upload the files using it, it gave me 302 error & when I searched for it , it gave me the solution that you must not be havning any kind of redirection during upload. So, I removed htaccess file from it as well as there is no redirection inside upload function. Here is my upload function which contains code of uploading which I got from swfupload site.


Code:
function testUpload()
    {
        if (isset($_POST["PHPSESSID"])) {
            session_id($_POST["PHPSESSID"]);
        } else if (isset($_GET["PHPSESSID"])) {
            session_id($_GET["PHPSESSID"]);
        }
    
        session_start();
    
    
        $POST_MAX_SIZE = ini_get('post_max_size');
        $unit = strtoupper(substr($POST_MAX_SIZE, -1));
        $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
    
        if ((int)$_SERVER['CONTENT_LENGTH'] > $multiplier*(int)$POST_MAX_SIZE && $POST_MAX_SIZE) {
            header("HTTP/1.1 500 Internal Server Error"); // This will trigger an uploadError event in SWFUpload
            echo "POST exceeded maximum allowed size.";
            exit(0);
        }
    
    
        $save_path ="./uploads/tmpFiles";                // The path were we will save the file (getcwd() may not be reliable and should be tested in your environment)
        
        $upload_name = "Filedata";
        $max_file_size_in_bytes = 2147483647;                // 2GB in bytes
        $extension_whitelist = array("jpg", "gif", "png");    // Allowed file extensions
        $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-';                // Characters allowed in the file name (in a Regular Expression format)
        
    // Other variables    
        $MAX_FILENAME_LENGTH = 260;
        $file_name = "";
        $file_extension = "";
        $uploadErrors = array(
            0=>"There is no error, the file uploaded with success",
            1=>"The uploaded file exceeds the upload_max_filesize directive in php.ini",
            2=>"The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form",
            3=>"The uploaded file was only partially uploaded",
            4=>"No file was uploaded",
            6=>"Missing a temporary folder"
    
        );
    
    
    // Validate the upload
        if (!isset($_FILES[$upload_name])) {
            echo "No upload found in \$_FILES for " . $upload_name;
            exit(0);
        } else if (isset($_FILES[$upload_name]["error"]) && $_FILES[$upload_name]["error"] != 0) {
            echo $uploadErrors[$_FILES[$upload_name]["error"]];
            exit(0);
        } else if (!isset($_FILES[$upload_name]["tmp_name"]) || !@is_uploaded_file($_FILES[$upload_name]["tmp_name"])) {
            echo "Upload failed is_uploaded_file test.";
            exit(0);
        } else if (!isset($_FILES[$upload_name]['name'])) {
            echo "File has no name.";
            exit(0);
        }
        
    // Validate the file size (Warning: the largest files supported by this code is 2GB)
        $file_size = @filesize($_FILES[$upload_name]["tmp_name"]);
        if (!$file_size || $file_size > $max_file_size_in_bytes) {
            echo "File exceeds the maximum allowed size";
            exit(0);
        }
        
        if ($file_size <= 0) {
            echo "File size outside allowed lower bound";
            exit(0);
        }
    
    
    // Validate file name (for our purposes we'll just remove invalid characters)
        $file_name = preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
        if (strlen($file_name) == 0 || strlen($file_name) > $MAX_FILENAME_LENGTH) {
            echo "Invalid file name";
            exit(0);
        }
    
    
    // Validate that we won't over-write an existing file
        if (file_exists($save_path . $file_name)) {
            echo "File with this name already exists";
            exit(0);
        }
    
        $path_info = pathinfo($_FILES[$upload_name]['name']);
        $file_extension = $path_info["extension"];
        $is_valid_extension = false;
        foreach ($extension_whitelist as $extension) {
            if (strcasecmp($file_extension, $extension) == 0) {
                $is_valid_extension = true;
                break;
            }
        }
        if (!$is_valid_extension) {
            echo "Invalid file extension";
            exit(0);
        }
      
        if (!@move_uploaded_file($_FILES[$upload_name]["tmp_name"], $save_path.$file_name)) {
            echo "File could not be saved.";
            exit(0);
        }
    
        exit(0);
    
        }
I tried but not able to find out why 302 error comes. Please help me if anyone from you guys have integrated swfupload with CI. Thanks in advance.




Theme © iAndrew 2016 - Forum software by © MyBB