Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Uploadify Session
  • Today I get Uploadify from this site.during I take the multi example,I got a problem. In the upload.php file,I tried to save "$_FILES['Filedata']['name']" into a session but I failured.
    My codes :

    <?php<br />// JQuery File Upload Plugin v1.4.1 by RonnieSan - (C)2009 Ronnie Garcia
    session_start();

    if (!empty($_FILES)) {
    $tempFile = $_FILES['Filedata']['tmp_name'];
    $targetPath = $_SERVER['DOCUMENT_ROOT'] . $_GET['folder'] . '/';
    $targetFile = str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];

    $_SESSION['data'] =$_FILES['Filedata']['name'];
    $_SESSION['data'] = "222";
    // Uncomment the following line if you want to make the directory if it doesn't exist
    // mkdir(str_replace('//','/',$targetPath), 0755, true);

    move_uploaded_file($tempFile,$targetFile);

    }

    echo '1';
    print_r($_SESSION['data']);
    ?>

    I am chinese ,may be there are some wrong in my word. Sorry
    Any one Can help me? Waitting for help.Best Regards.
  • Your script looks ok to me - but it will save '222' in the session, not the filename.

    Try

    $_SESSION['data'][] = $_FILES['Filename']['name'];

    This will store each file uploaded in your $_SESSION['data'];
  • smokinaces said:
    Your script looks ok to me - but it will save '222' in the session, not the filename.

    Try

    $_SESSION['data'][] = $_FILES['Filename']['name'];

    This will store each file uploaded in your $_SESSION['data'];



    Dear smokinaces

    Thank you for helping work on my problems;I had tried what you told me. But I still can't print the session,I tried wether i set php(session.auto_start =1 or session.auto_start=0);

    I set you my codes below:


    //uploadify/upload.php
    <?php<br />
    // JQuery File Upload Plugin v1.4.1 by RonnieSan - (C)2009 Ronnie Garcia
    if (!empty($_FILES)) {
    $tempFile = $_FILES['Filedata']['tmp_name'];
    $targetPath = $_SERVER['DOCUMENT_ROOT'] . $_GET['folder'] . '/';
    $targetFile = str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];

    // Uncomment the following line if you want to make the directory if it doesn't exist
    // mkdir(str_replace('//','/',$targetPath), 0755, true);
    session_start();
    $_SESSION['data'][]= $_FILES['Filename']['name'];
    move_uploaded_file($tempFile,$targetFile);
    }
    print_r($_SESSION);
    echo '1';

    ?>
    if I view the ./uploadify/upload.php But it gives me Array()1.
    then I go to index.php.
    I added
    <?php <br />session_start();
    print_r($_SESSION);
    ?> to index.php just below the tag; But I also get Array();



    I come to you ,whether you also have my problems,or you can see where I am wrong? waiting for your help

    Best regards;

    my gtalk is: legend.tao@edoctor1.com

    if you also have one , you can conntect me though that.

    So sorry for my English!
  • The session is not being passed as Uploadify is flash based and does not pass cookies along with the request. I'm looking for a solution to this issue also, my javascript is in an external file so I cant use php hacks to add the session to the url etc, which is just nasty anyway. If I cant use sessions the I will be forced to look else where for this functionality.
  • lperry65 said:
    The session is not being passed as Uploadify is flash based and does not pass cookies along with the request. I'm looking for a solution to this issue also, my javascript is in an external file so I cant use php hacks to add the session to the url etc, which is just nasty anyway. If I cant use sessions the I will be forced to look else where for this functionality.



    Hi lperry65:

    Because of the question which i have described over.I don't have any solution to the session problems. So I change my way: First,I upload files into my servers; Second,I put the name,size,type and save path into a array ,and put it into the upload_files table in my database; and I write a function which will return the id of the above array(we call it upload_id) ; At last, when I click the submit button at the bottom of the page,at this moment,I will update the upload_files table at the condition :where the id equalls upload_id.
    I think it is a very bad idea.But at the moment,I can't think any ideas any more.If you got a better idea,Please share it with me;

    Best Regards;