SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Oct 2009
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP Uploading and merging txt files

    I was just wondering that if there was a way to upload in php, txt files and then all those files that are uploaded to merge them in a single txt file in a folder

  2. #2
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Sure. Once you receive them in the $_FILES array, sanitise the received data (check that they are what you expected) and then loop through them:
    PHP Code:
    $dest 'destination.txt';
    foreach (
    $files as $file) {
      
    file_put_contents($destfile_get_contents($file), FILE_APPEND);

    This simple procedure will mean that the uploaded files are destroyed, because they haven't been moved from their temporary location.

  3. #3
    SitePoint Member
    Join Date
    Oct 2009
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey thanks that worked just fine, 2nd time I'm saved by this forum


Bookmarks

Posting Permissions

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