We have found that a few special characters and 2 or more consecutive spaces in a file name are causing us an IO Error.

In one particular case the filename was 'Packet SFD  1358746185.pdf" - this file produced the IO Error every time in IE 9 (failed in Chrome with a slightly different error). I changed the file name to "Packet SFD 1358746185.pdf" and it worked flawlessly every time.

So my question is, is there a way at File Selection to Check/Manipulate the file name so that it doesn't fail?

It doesn't appear as there is anything I can do on the server side.

2

(6 replies, posted in General discussion)

Davit, I pulled everything from the latest GIT  and it seems to be working now. Maybe i didn't over write a file from 1.4 when I placed the new libraries on the server? It was running the HTML5 run time.

If you'd like I can diff the 2 sets of files to see if I can find the difference. Or we can leave the issue as is, since it is obviously fixed.

3

(6 replies, posted in General discussion)

davit wrote:

Just rechecked, seems to be on it's place, while they've really dropped file.fileName, there's a plug for this in the code. Maybe you are using old cached js file on Firefox 7?

I had just realized that I am using FF7 - not sure when it updated. Probably when I installed Ubuntu 11.10 Beta.

I dumped the proxy cache on the server and still have the issue. Should I just pull files straight from Git and see if they remedy the issue?

4

(6 replies, posted in General discussion)

Afternoon everyone,
I just updated to the 1.5b PLUpload.
I have now noticed that in the FilesAdded (only event I have checked so far)
the file objects name properties are null - in FireFox.
However, this same code works in Chrome just fine.

.bind('FilesAdded', function(up, files){
    Ext.each(files, function(file, index, ogArg ){
        Ext.getCmp('docFile').setValue(file.name);
    });
});

Any insight into this?

Thanks

5

(1 replies, posted in General discussion)

flashuploader.bind('FileUploaded', function(up, file, res) {
            if (flashuploader.total.queued == 0) {
        //do your alert here.
    })

6

(3 replies, posted in General discussion)

Just curious if anyone has a work around for chromes file selection window showing "Custom Files" and not showing any of your filtered file types?

In my case I have XLS, XLSX files set in the filter, and the only visible file types are JPEG, even though that is not in the filter at all - if I try to add them it says its an invalid file type - which is expected.  But my users are complaining of having to change the file type to "All Files" to be able to upload the correct content. Which also ruins the point of the filters at all.

Any clues?

read through the list of selected files from the file input, create an unordered list of those file names? There is your queue...all the other functionality of removing files and what not is just relatively simple JS.

8

(15 replies, posted in General discussion)

Carmicheal wrote:

I love Apple and everything they do so no it is not a fad and in fact it is already so perfect that it will never change
Still too pricey for now. Hoping prices come down soon.

Who said it's a fad? I'm a mobile nut job smile
I'll start developing mobile versions of things now, before I even put design thought into a desktop version wink

I'm not a fan of Apple's eco system, prices, or devices, so I'll stick with the more 'open' (loose term these days) Android.

But, like I said, I have no clue if PLUpload works on iOS, I assume it will because Safari is WebKit. We're getting an iPad2 to test with in the office shortly.

This has come up on here a few times, I ended up with this on mine:

flashuploader.bind('BeforeUpload', function (up, file) {
            var id = file.id;
            flashuploader.settings.multipart_params = {
                param0: value,
                param1: value
            };
        });

10

(15 replies, posted in General discussion)

Just as an FYI, Android versions 2.2 and above allow uploading from with in the browser and PLUpload does an amazing job  with the HTML 5 runtime on these devices. We have several Motorola Xoom tablets that we are in beta testing with and very little has been changed to make them work.

Word of warning though, Android does not properly render the 'overflow' properties in all cases.

I don't know anything about Apple products, but can vouch for the latest Android products.

flashuploader.bind('BeforeUpload', function (up, file) {
            var id = file.id;
            flashuploader.settings.multipart_params = {
                entityID: Ext.getCmp('cboSite').getValue(),
                Project: Ext.getCmp('cboProject').getValue(),
                fotoType: Ext.getCmp('fotoType').getValue(),
                type: upType,
                site: Ext.getCmp('cboSite').getRawValue(),
                isPublish: document.getElementById('pub_' + id).checked,
                file_name: file.name
            };

12

(1 replies, posted in General discussion)

I believe that you can - $_REQUEST['fileName'] - in the php file and it will give you the randomly generated ID of the file.

I remember seeing somewhere in source an explanation of how it is generated. If I can find it again quickly I will post it.

13

(4 replies, posted in General discussion)

Again, I don't deal with accented characters, thank goodness for American English.... I did how ever find this

function removeaccents($string)
{
  return strtr($string,
"ŠŒŽšœžŸ¥µÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝß
àáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿ",
"SOZsozYYuAAAAAAACEEEEIIIIDNOOOOOOUUUUYsaaaaaaaceeeeiiiionoooooouuuuyy");

Pretty much you pass in the string to be translated, a string of chars to remove, and a string of values to replace the removed ones with (looks like the are paired $StringA[0] == $StringB[0]).

See if it helps? Looks like it gets everything you need?
Here is the PHP help file on the function:
http://php.net/manual/en/function.strtr.php

14

(4 replies, posted in General discussion)

Hypocrite wrote:

I am trying to implement code to the upload.php which cleans the filename and gives it a unique name.

Could some help what is wrong with the following code:

<?php
/**
 * upload.php
 *
 * Copyright 2009, Moxiecode Systems AB
 * Released under GPL License.
 *
 * License: http://www.plupload.com/license
 * Contributing: http://www.plupload.com/contributing
 */

    // HTTP headers for no cache etc
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
    header("Cache-Control: no-store, no-cache, must-revalidate");
    header("Cache-Control: post-check=0, pre-check=0", false);
    header("Pragma: no-cache");

    // Settings
    
    // $targetDir = ini_get("upload_tmp_dir") . DIRECTORY_SEPARATOR . "plupload";
    $targetDir = "/opt/www/wwwfiles/lataukset/";
    $cleanupTargetDir = false; // Remove old files
    $maxFileAge = 60 * 60; // Temp file age in seconds

    // 5 minutes execution time
    @set_time_limit(5 * 60);

    // Uncomment this one to fake upload time
    // usleep(5000);

    // Get parameters
    $chunk = isset($_REQUEST["chunk"]) ? $_REQUEST["chunk"] : 0;
    $chunks = isset($_REQUEST["chunks"]) ? $_REQUEST["chunks"] : 0;
    $fileName = isset($_REQUEST["name"]) ? $_REQUEST["name"] : '';

function cleanFileName($str) {
  $accent_array = array(
    'e' => array('é','è','ê','ë'),
    'E' => array('É','È','Ê','Ë'),
    'a' => array('á','à','â','ä','å','ª'),
    'A' => array('Á','À','Â','Ä','Å'),
    'i' => array('ì','í','î','ï'),
    'o' => array('ò','ó','õ','ô','ö'),
    'u' => array('ù','ú','û','ü'),
    'n' => array('ñ'),
    'c' => array('ç'),
    'ae' => array('æ'),
    'oe' => array('œ'),
    'y' => array('ÿ')
    );
   
   foreach($accent_array as $acc_key => $acc_val_array) {
      $str = str_replace($acc_val_array, $acc_key, $str);
   }
   return $str;
}
    $fileName = cleanFileName(date("Ymd")."_".$fileName);

    // Make sure the fileName is unique but only if chunking is disabled
    if ($chunks < 2 && file_exists($targetDir . DIRECTORY_SEPARATOR . $fileName)) {
        $ext = strrpos($fileName, '.');
        $fileName_a = substr($fileName, 0, $ext);
        $fileName_b = substr($fileName, $ext);

        $count = 1;
        while (file_exists($targetDir . DIRECTORY_SEPARATOR . $fileName_a . '_' . $count . $fileName_b))
            $count++;

        $fileName = $fileName_a . '_' . $count . $fileName_b;
    }

    // Create target dir
    if (!file_exists($targetDir))
        @mkdir($targetDir);

    // Remove old temp files
    if (is_dir($targetDir) && ($dir = opendir($targetDir))) {
        while (($file = readdir($dir)) !== false) {
            $filePath = $targetDir . DIRECTORY_SEPARATOR . $file;

            // Remove temp files if they are older than the max age
            if (preg_match('/\\.tmp$/', $file) && (filemtime($filePath) < time() - $maxFileAge))
                @unlink($filePath);
        }

        closedir($dir);
    } else
        die('{"jsonrpc" : "2.0", "error" : {"code": 100, "message": "Failed to open temp directory."}, "id" : "id"}');

    // Look for the content type header
    if (isset($_SERVER["HTTP_CONTENT_TYPE"]))
        $contentType = $_SERVER["HTTP_CONTENT_TYPE"];

    if (isset($_SERVER["CONTENT_TYPE"]))
        $contentType = $_SERVER["CONTENT_TYPE"];

    // Handle non multipart uploads older WebKit versions didn't support multipart in HTML5
    if (strpos($contentType, "multipart") !== false) {
        if (isset($_FILES['file']['tmp_name']) && is_uploaded_file($_FILES['file']['tmp_name'])) {
            // Open temp file
            $out = fopen($targetDir . DIRECTORY_SEPARATOR . $fileName, $chunk == 0 ? "wb" : "ab");
            if ($out) {
                // Read binary input stream and append it to temp file
                $in = fopen($_FILES['file']['tmp_name'], "rb");

                if ($in) {
                    while ($buff = fread($in, 4096))
                        fwrite($out, $buff);
                } else
                    die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');
                fclose($in);
                fclose($out);
                @unlink($_FILES['file']['tmp_name']);
            } else
                die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}');
        } else
            die('{"jsonrpc" : "2.0", "error" : {"code": 103, "message": "Failed to move uploaded file."}, "id" : "id"}');
    } else {
        // Open temp file
        $out = fopen($targetDir . DIRECTORY_SEPARATOR . $fileName, $chunk == 0 ? "wb" : "ab");
        if ($out) {
            // Read binary input stream and append it to temp file
            $in = fopen("php://input", "rb");

            if ($in) {
                while ($buff = fread($in, 4096))
                    fwrite($out, $buff);
            } else
                die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');

            fclose($in);
            fclose($out);
        } else
            die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}');
    }

    // Return JSON-RPC response
    die('{"jsonrpc" : "2.0", "result" : null, "id" : "id"}');
?>

Little more info on what's not working? is a string not being returned? Just from 2 seconds of looking I would think you are only going through the first char of the particular element of the array...I don't deal with charaters that aren't on a U.S. English keyboard...not even sure how to get them...so I'm probably of little help here other than suggesting a regular expression might work better?

davit wrote:

I've searched around for known issues and it seems that Chrome (and probably whole WebKit) is historically bad at handling dynamic images and canvas (since version 5 I think). Neither of the tickets I've found were closed or had a response from core team, so I guess they are still actual.

I'm going to undertake some tests to prove or reject this. It'd better be a problem on our side, really neutral

Davit, I appreciate you effort on this.
It's somewhat sad that Webkit/Chrome is not handling the Canvas like they should, especially since WebKit seems to be the defacto standard for HTML5 browsing.

davit wrote:

Chrome seems to be leaking memory. Apparently at some point it is not able to allocate enough of it anymore. Although I wasn't able to repeat the issue, I simply ran out of memory, somewhere after 100-th resized and uploaded image  and had to kill the process to unhang the browser.

I guess it has something to have with Chrome's "semantic" approach to garbage collection neutral

Grrrrreeeeeeeaaaaaatttt.

The 80 pictures was only the most recent run, that number varies, but it does seem that Only the first 10 or so are properly resampled in chrome. Other browsers seem to be fine. I have not tested other runtimes in Chrome.

It also seems to be that using Drag and Drop makes the situation appear more often. If I use the file dialog I can get about the first 20 properly resampled (But honestly that might just be a fluke)

I will very often upload 100+ photos.

Also the particular photos I was using as a test batch are very high resolution(12mp cammera, each picture 3000+ px wide.) and I am resizing to 1280 x 1024 with quality set on 80.

$("#upCon").pluploadQueue({
            runtimes: 'html5,flash,html4',
            url: 'data/common/upload.php',
            max_file_size: '10mb',
            filters: [{
                title: "Image files",
                extensions: "jpg,gif,png"
            }],
            resize: {
                width: 1280,
                height: 1024,
                quality: 80
            },

            // Flash settings
            flash_swf_url: 'lib/plupload/plupload.flash.swf'
        });

Curious if anyone has ever seen re sampling be hit or miss with Google's Chrome Browser. More Miss than Hit using the HTML5 run time.

If I upload 80 pictures, first 10 are re sampled then the rest aren't and come across full quality/size.

Anyone seen Chrome or other browsers exhibit this behavior?

Glad we caught it! Could have been out of disk space in a hurry!

19

(5 replies, posted in General discussion)

Davit,
Only seems to happen when using multiple run times and setting the gears init file as the last JS file for the runtimes.

I have dropped gears support for now, it rarely got hit before one of the other Flash or HTML5 runtimes any ways.

Thanks for testing.

20

(5 replies, posted in General discussion)

Good Morning Davit,
Anything new on this issue?

21

(5 replies, posted in General discussion)

Bump. Anything from any one?

22

(2 replies, posted in General discussion)

It's not quite something that you "install"....

Firebug is yelling at me about a "ActiveXObject is undefined" in the gears_init.js file.
On this line:
factory = new ActiveXObject('Gears.Factory');

Firebug doesn't complain unless I have it set to "break on all errors"

Anyone else experience this or have a solution? It's not a huge deal and users never see it -  but its kind of a debugging pain for other pieces of my app. I have to hit 'play' or 'continue' every time that the page loads.

24

(2 replies, posted in General discussion)

i may have this wrong. $_SERVER['HTTP_REFERER']

25

(8 replies, posted in General discussion)

Use the before upload event, other wise your data is likely blank.