Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Feb 2006
    Posts
    262
    Thanks
    23
    Thanked 1 Time in 1 Post

    Post upload image + create txt file same name

    Good day to you all,
    Is there somebody that can help me or at least point me on how to construct a piece of code that :

    each time a user upload an image, a txt file is created with the samename.txt in a specific folder ?

    Thanks !

  • #2
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,039
    Thanks
    19
    Thanked 42 Times in 42 Posts
    functions -
    mkdir() - http://php.net/mkdir
    thats it basically ..call the function on upload and hey presto...

  • #3
    Regular Coder
    Join Date
    Feb 2006
    Posts
    262
    Thanks
    23
    Thanked 1 Time in 1 Post
    Here's where I am now...

    PHP Code:

    //set where you want to store files
    //in this example we keep file in folder upload
    //$HTTP_POST_FILES['ufile']['name']; = upload file name
    //for example upload file name cartoon.gif . $path will be upload/cartoon.gif
    $path1"Upload/".$HTTP_POST_FILES['ufile']['name'][0];
    $path2"Upload/".$HTTP_POST_FILES['ufile']['name'][1];
    $path3"Upload/".$HTTP_POST_FILES['ufile']['name'][2];
    $path4"Upload/".$HTTP_POST_FILES['ufile']['name'][3];
    $path5"Upload/".$HTTP_POST_FILES['ufile']['name'][4];


    //copy file to where you want to store file
    copy($HTTP_POST_FILES['ufile']['tmp_name'][0], $path1);
    copy($HTTP_POST_FILES['ufile']['tmp_name'][1], $path2);
    copy($HTTP_POST_FILES['ufile']['tmp_name'][2], $path3);
    copy($HTTP_POST_FILES['ufile']['tmp_name'][3], $path4);
    copy($HTTP_POST_FILES['ufile']['tmp_name'][4], $path5);


     
    $file "model_commentaire.html"// A template or blank file
        
    $newfile "Commentaires/model_commentaire.html"// where file gets created

    $name0 substr($HTTP_POST_FILES['ufile']['name'][0], 0strrpos($HTTP_POST_FILES['ufile']['name'][0], '.'));          // striping the extension
    rename("Commentaires/model_commentaire.html" "Commentaires/".$name0.".html");        // rename to the name of the image
    $named0 "Commentaires/".$name0.".html";       // filename and path to var
    $commentaires00 fopen($named0'w');       // Open file
    $write $fwrite($commentaires00$_POST['commentaires0']);      // write post commentaires0 to file
    fclose($commentaires00);       // close file


    if (!copy($file$newfile)) {
      } 

  • #4
    Regular Coder
    Join Date
    Feb 2006
    Posts
    262
    Thanks
    23
    Thanked 1 Time in 1 Post
    Resolved


  •  

    Posting Permissions

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