Upload image before parent creation?

Discussion in 'Programming' started by Triexa, Mar 1, 2010.

  1. #1
    So let's say you are posting a new article, post, whatever... and want to upload an image.

    I have an images table that links to the article_id, but the article_id is not yet known since it hasn't been created it. This is obviously a non-issue on edit.

    Just wondering, is there a general way to go about handling this?

    I need to store a bunch of details about the image, which is fine - it's just the link to the article_id that is missing. Due to a foreign key constraint I can't really just assign it a (temporary) value of 0 or something, either...
     
    Triexa, Mar 1, 2010 IP
  2. Sky AK47

    Sky AK47 Member

    Messages:
    298
    Likes Received:
    8
    Best Answers:
    1
    Trophy Points:
    45
    #2
    Add the article before uploading then, ajax perhaps?
     
    Sky AK47, Mar 1, 2010 IP
  3. Triexa

    Triexa Active Member

    Messages:
    580
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #3
    The article details may be incomplete, may contain errors, etc.
     
    Triexa, Mar 1, 2010 IP
  4. Sky AK47

    Sky AK47 Member

    Messages:
    298
    Likes Received:
    8
    Best Answers:
    1
    Trophy Points:
    45
    #4
    Eh..the user wont know. Upload the image, and secretly add the article and then let the user submit which would update the earlier submitted fields?
     
    Sky AK47, Mar 1, 2010 IP
  5. darkdrgn2k

    darkdrgn2k Active Member

    Messages:
    159
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #5
    Store the image in a temporary location and coocie its existance?
    then when you save you move it to a perminante location

    then once in a while wipe the temp files
     
    darkdrgn2k, Mar 4, 2010 IP
  6. NeoCambell

    NeoCambell Peon

    Messages:
    456
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I agree with darkdrgn2k. It is the best method.
     
    NeoCambell, Mar 4, 2010 IP