OK I searched, but didn't find the answer
Results 1 to 3 of 3

Thread: OK I searched, but didn't find the answer

  1. #1
    Junior Member
    Join Date
    Nov 2003
    Posts
    13

    OK I searched, but didn't find the answer

    Is it possible to use fopen to change the filename once you close it? I have a file that needs to be uploaded daily and once I am done with it each day, I would like the date to be appended to the filename so the next day I don't have to manually rename the previous days file. Boy that sounds confusing just writing it.

    But, is it possible that on fclose the filename has the date appended?

    So say I upload orders.txt and load my page. When I am done, I want the orders.txt to automatically be renamed orders20031911.txt. See where I am going with this?

    Thanks for All your help!

    Regards,
    Eric

  2. #2
    Senior Member
    Join Date
    Sep 2003
    Posts
    273
    There may or may not be.. I did a quick check through the Manual but didnt find anything.. but i did think of a work around.

    After reading orders.txt you could create a newfile called whatever you want with the text of orders.txt and then delete orders.txt using unlink()

    hth

  3. #3
    Member
    Join Date
    Nov 2003
    Location
    Cebu City, Philippines
    Posts
    45
    Why dont you just change the filename of the file when the is uploaded. When you upload a file, info about that file is contained on the $_FILES array. for example you have an input field of type "file" which is named "pcfile". on the $_FILES array

    $_FILES['pcfile'] contains for members

    $_FILES['pcfile']['name'] -> true filename of the file
    $_FILES['pcfile']['tmp_name'] --> path to the tmp file on the server
    ...
    ...
    The other info you dont need

    when you upload file to a directory on the webroot you need to copy the tmp_file to the directory on the web root or whatever by running

    copy ( $_FILES['pcfile']['tmp_name'], '/path/to/file/'.$_FILES['name'].date("Ydm", time());

    im not really sure of the indexes of the $_FILES['pcfile'] array to be sure make a test php script that contains only the following

    while(list($key, $value) = each($_FILES['pcfile']))
    {
    echo $key.': '.$value;
    }

    this will echo the indexes and the values of those indexes of $_FILES['pcfile'] array

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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