+ Reply to Thread
Results 1 to 3 of 3

Thread: Sessions and files

  1. #1
    nfrandsen is offline Junior Member
    Join Date
    Dec 2008
    Posts
    23

    Default Sessions and files

    I am trying to create a 4 page form, where the user can input various pieces of info and upload some images and then the last form is a confirmation form where if the user confirms then its all saved to my database. Similar deal to a standard ebay form for example. Does anyone have any suggestions how best to go about this? I plan to allow users to upload images on form2, how do i take care of this in a way where they only get added if the user confirms on page4? Is there any way I can simply add the images to the Zend Session like I can with normal zend form text elements or is this not possible. Another way I was considering was to simply upload them to a temp folder named after the users id, renaming the files to timestamps and storing these filenames in the session then if user confirms, then my model can grab the filenames of the uploaded files and move them into their correct folder, resize them and store their address in the database. Is this the best way to go about it or does anyone have any better suggestions. One problem with the above approach is that my server will after a while contain a number of images in the temporary folder that have been uploaded but where the user hasn't completed the form, I would thus need to delete these later using some kind of script. This is not a big problem I guess, still if anyone has any suggestions as to any better way to tackle this problem I would love to know! Thanks

  2. #2
    clearvision is offline Junior Member
    Join Date
    Jul 2009
    Posts
    3

    Default

    that's right, a temp folder or a temp db table that would store that data will do the job.
    In the case of a temp folder I would create a subdirectory for the session (that is, directory name = session id) and create script that would be fired up at the end of the session. The end of the session would mean: 1. The user has submitted the form, action: move the valid data to the designated location and delete the temp subdirectory; 2. the user left without completing the form properly or in a timely manner (= session timeout), delete the temp subdirectory.
    As to a db table, it depends on you app design whether or not this would be more sensible.
    You may also want to take a look at these answers:

    PHP - Store Images in SESSION data ??? - Stack Overflow
    I would also advise against storing images in the session variable.

  3. #3
    nfrandsen is offline Junior Member
    Join Date
    Dec 2008
    Posts
    23

    Default

    excellent, thanks a lot for quick response, really appreciate it.. I think I will just store them in a sub directory as I don't store any other images in my db.
    I've been reading around quite a bit about sessions, haven't really done any real web development before, I am a student and more familiar with standard C, C++..
    When assigning a session using $formSession = new Zend_Session_Namespace('registerForm'); this automatically creates a session and sets a unique session id, right? And why use the namespace, is it so you can have different setting for different types of sessions? and finally do you access the underlying php sessions by $formSession->__get('id'); ??
    Last edited by nfrandsen; 07-02-2009 at 12:02 AM.

+ Reply to Thread

Similar Threads

  1. .phtml files are loading before .php files
    By Lucrix in forum Installation & Configuration
    Replies: 4
    Last Post: 02-20-2009, 03:27 PM
  2. sessions don't work
    By pilsudski in forum Authentication & Authorization
    Replies: 1
    Last Post: 01-12-2009, 10:51 PM
  3. Any way to include '.phtml' files in other files
    By bluesapphire in forum Model-View-Controller (MVC)
    Replies: 1
    Last Post: 06-12-2008, 04:18 PM
  4. Sessions way of life
    By eric.cat in forum Authentication & Authorization
    Replies: 1
    Last Post: 05-21-2008, 05:58 PM
  5. Server Sessions vs. Client Sessions?
    By Elemental in forum Concepts, Ideas, Planning
    Replies: 0
    Last Post: 10-07-2007, 05:21 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts