1. #51
    Ext User
    Join Date
    Sep 2007
    Posts
    11
    Vote Rating
    0
    southside is on a distinguished road

      0  

    Default


    Thanks MaximGB I will have a look, sorry if this is elementary but I am just finding my way and appreciate the help.

  2. #52
    Ext User
    Join Date
    Sep 2007
    Posts
    11
    Vote Rating
    0
    southside is on a distinguished road

      0  

    Default


    Quote Originally Posted by MaximGB View Post
    The upload-dialog-request.php isn't missing , the code of upload-dialog-request.php which I use in the demo is following:
    Code:
    <?php
    $response = array(
        'success' => true
    );
    echo json_encode($response);
    ?>
    As you can see it doesn't save uploaded file anywhere and just returns success response in any case. I don't want all that files that visitors uploaded during the demo testing

    If you are using php on the server side then you can get all data required to handle an uploaded file in the $_FILES['file'] variable. The PHP's uploaded file handling is described here
    http://www.php.net/manual/en/features.file-upload.php
    Hi Maxim;

    Do you have a zip of full project to assist in my learning curve, I am new to this and eager to learn.

    I know some are sensitive about being asked to supply their hard work so if this applies to you then let me know and I will trudge along through the forum until I can pull together a working example that I can build on.

    Starting from a blank sheet may be to steep for me at this time.

    Thanks for your help.

    SC

  3. #53
    Sencha Premium Member MaximGB's Avatar
    Join Date
    Jun 2007
    Location
    Moscow, Russia
    Posts
    508
    Vote Rating
    5
    MaximGB is on a distinguished road

      0  

    Default


    Quote Originally Posted by southside View Post
    Hi Maxim;
    Hi southside

    Quote Originally Posted by southside View Post
    Do you have a zip of full project to assist in my learning curve, I am new to this and eager to learn.
    Yes I do , now it contains 1391 files in 258 folders, and I guess it won't help you.

    Quote Originally Posted by southside View Post
    I know some are sensitive about being asked to supply their hard work so if this applies to you then let me know and I will trudge along through the forum until I can pull together a working example that I can build on.
    No I am not such a sensitive, but I don't understand you request, if you need examples use extjs's examples that go with distribution. If you have questions ask them here or at other forums devoted to those technologies you have questions in.

    Quote Originally Posted by southside View Post
    Starting from a blank sheet may be to steep for me at this time. Thanks for your help. SC
    "This is the talk for the poor peoples sake". If you have questions for which you can't find answers in the docs, books, net, then you should ask those questions.
    Use the force - read the source.

  4. #54
    Ext User
    Join Date
    Sep 2007
    Posts
    11
    Vote Rating
    0
    southside is on a distinguished road

      0  

    Default


    Hi Maxim;

    I have managed to get the files saving to my server location using your upload system.

    I see threads about a response cannot be sent back from a php upload page.

    Your code below is in a php page and sends an OK back to the dialog I assume.

    I have tried to do the same in my php page and had no message returned to the dialog.

    If I use your code in your upload-dialog-request.php I get the OK.

    So my JSON I guess is running fine - my server is PHP 4.3.9 with json 1.2.1.

    Can you help, I just need to know how to tell my php page to send th OK on success?

    I thought I could just use the "echo json_encode($response);" element and have $response = whatever?

    <?php
    $response = array(
    'success' => true
    );
    echo json_encode($response);
    ?>

  5. #55
    Sencha Premium Member MaximGB's Avatar
    Join Date
    Jun 2007
    Location
    Moscow, Russia
    Posts
    508
    Vote Rating
    5
    MaximGB is on a distinguished road

      0  

    Default


    You should return a json-message in following format:
    Code:
    {
      success: true of false,
      error: 'String with error or message, with member also can be named message',
      ...
      any other your code private data
      ...
    }
    There is only one required member in this message, it's 'success' flag.
    Using php the message creation code should be like this:
    Code:
    $response = array();
    if ($file_uploaded) {
       $response['success'] = true;
       $response['message'] = 'File uploaded successfully';
    else {
       $response['success'] = false;
       $response['message'] = 'Some error occurred during file upload';
    }
    echo json_encode($response);
    I advise you to install Firefox with Firebug plugin (if you still haven't done it) and see what json-message your code is actualy returning.
    Use the force - read the source.

  6. #56
    Ext User
    Join Date
    Sep 2007
    Posts
    11
    Vote Rating
    0
    southside is on a distinguished road

      0  

    Default


    Quote Originally Posted by MaximGB View Post
    You should return a json-message in following format:
    Code:
    {
      success: true of false,
      error: 'String with error or message, with member also can be named message',
      ...
      any other your code private data
      ...
    }
    There is only one required member in this message, it's 'success' flag.
    Using php the message creation code should be like this:
    Code:
    $response = array();
    if ($file_uploaded) {
       $response['success'] = true;
       $response['message'] = 'File uploaded successfully';
    else {
       $response['success'] = false;
       $response['message'] = 'Some error occurred during file upload';
    }
    echo json_encode($response);
    I advise you to install Firefox with Firebug plugin (if you still haven't done it) and see what json-message your code is actualy returning.
    Maxim;

    I think I see, I am a bit unsure though.

    Say I am using the basic php upload file like below, this uploads the file but i obviously get no response back via json. (Ps I am using firebug to watch for response from your dialog upload utility).

    When I try and enter the response code into the php upload your dialog upload returns an error and does not upload the file eg I get a red cross.

    So I guess i am doing it wrong can you advise how the response should be placed in the simple php upload file.

    Once I get the idea I will be able to work adding to it out myself.

    Hope you can help.

    SC

    <?php

    $uploaddir = 'files/';
    $uploadfile = $uploaddir . basename($_FILES['file']['name']);

    echo '<pre>';
    if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)) {

    echo "File is valid, and was successfully uploaded.\n";
    } else {
    echo "Possible file upload attack!\n";
    }

    echo 'Here is some more debugging info:';
    print_r($_FILES);

    print "</pre>";

    ?>

  7. #57
    Ext User
    Join Date
    Sep 2007
    Posts
    11
    Vote Rating
    0
    southside is on a distinguished road

      0  

    Default


    Hi Maxim;

    I have just managed to get it working using your code snippett as the basis.

    This returns "File uploaded successfully" into your dialog NOTES BOX, which is what I was trying to do.

    Is this correct.

    <?php

    $uploaddir = 'files/';
    $uploadfile = $uploaddir . basename($_FILES['file']['name']);

    $response = array();
    if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)) {
    $response['success'] = true;
    $response['message'] = 'File uploaded successfully';
    }
    else {
    $response['success'] = false;
    $response['message'] = 'Some error occurred during file upload';
    }
    echo json_encode($response);
    ?>

  8. #58
    Sencha Premium Member MaximGB's Avatar
    Join Date
    Jun 2007
    Location
    Moscow, Russia
    Posts
    508
    Vote Rating
    5
    MaximGB is on a distinguished road

      0  

    Default


    Yes it is.
    Use the force - read the source.

  9. #59
    Sencha - Community Support Team jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364
    Vote Rating
    81
    jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all

      0  

    Default


    Great job! I'm going to see if i can plug this into a back end for a client.

    I got sick of using SWF Upload.
    I was able to implement something like (dev): http://screencast.com/t/i2Hv2SC6

    But when i went to deploy it in production i had HTTP 403s being reported by SWF Uploader. HTML Forms worked great for the upload form, but SWF uploader just would NOT work w/ this web server. Sooo strange.

  10. #60
    Ext JS Premium Member milanz's Avatar
    Join Date
    Aug 2007
    Posts
    47
    Vote Rating
    0
    milanz is on a distinguished road

      0  

    Exclamation Extention case

    Extention case


    Awesome ux.

    Just found a small logic fix. Seems that the permitted_extensions does not take case into consideration. So 'jpg' is not the same as 'JPG' depending how it is named on the user's machine. Simply solved it by defining my allowed extensions in lower case and added the "toLowerCase" as below:

    PHP Code:
      getFileExtension : function(filename)
      {
        var 
    parts filename.split('.');
        if (
    parts.length == 1) {
          return 
    null;
        }
        else {
         return 
    parts.pop().toLowerCase();
        }
      }