Need help saving the name of a file to a txt file. Help!

Discussion in 'JavaScript' started by offthedome, May 23, 2012.

  1. #1
    I have a javascript that creates an image and uploads it to imgur.com. I want to then either
    1. Automatically save the name of the file locally to a txt file, or
    2. Allow a user to choose to save the file by clicking a button.
    Option 2 preferred. I just don't know how to do it. Help!
     
    offthedome, May 23, 2012 IP
  2. HostPlanz

    HostPlanz Well-Known Member

    Messages:
    449
    Likes Received:
    34
    Best Answers:
    4
    Trophy Points:
    130
    #2
    You need to do that stuff on the server side using PHP or some other server side scripting.
     
    HostPlanz, May 24, 2012 IP
  3. offthedome

    offthedome Active Member

    Messages:
    446
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    95
    #3
    That would be fine with me, but the image creator is in JavaScript, and I can't figure out how to get php to do that when the image creator is in javascript.
     
    offthedome, May 24, 2012 IP
  4. HostPlanz

    HostPlanz Well-Known Member

    Messages:
    449
    Likes Received:
    34
    Best Answers:
    4
    Trophy Points:
    130
    #4
    When the image is created, upload it to your server using an AJAX library like jQuery (I don't know how your code works so I can't tell you how to do that). Once the image is on your server, you can use PHP to do anything with it:

    *Like read the name file and store it in a .txt
    *Allow the user to download and save the file

    An image created in JS cannot be saved to the user's computer unless you dump that image (which is in RAM memory) to your server first.
     
    HostPlanz, May 24, 2012 IP
  5. offthedome

    offthedome Active Member

    Messages:
    446
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    95
    #5
    To reduce server load, I don't even keep the images locally. They all go to imgur.com. I really just want to save the file name!
     
    offthedome, May 24, 2012 IP
  6. HostPlanz

    HostPlanz Well-Known Member

    Messages:
    449
    Likes Received:
    34
    Best Answers:
    4
    Trophy Points:
    130
    #6
    Then using AJAX, you can send the file name to PHP and store it wherever you want.
     
    HostPlanz, May 25, 2012 IP
    KangBroke and sufalamtech like this.
  7. sufalamtech

    sufalamtech Peon

    Messages:
    116
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    As per my opinion 1st option is best to use it and save automatically.
     
    sufalamtech, May 31, 2012 IP