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
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    7
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Adding a last name to multiple uploaded files.

    Okay, so you guys had answered my question on how to do this on a single file, but now I need some help with doing it on multiple uploaded files.

    Code:
    <table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
      <tr>
    <form action="multiple_upload_ac.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
          <td width="100%"> 
            <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
              <tr> 
                <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
                  <label><font size="1">Please enter your name, last name first, separated 
                  by an underscore and number photo correctly. (ex. Smith_John):</font></label>
                  <br />
                  <input name="lastname" type="text" id="lastname" size="25">
                  </font></td>
              </tr>
              <tr> 
                <td> <input name="ufile[]" type="file" id="ufile[]" size="25" /></td>
              </tr>
              <tr> 
                <td> <input name="ufile[]" type="file" id="ufile[]" size="25" /></td>
              </tr>
              <tr> 
                <td> <input name="ufile[]" type="file" id="ufile[]" size="25" /></td>
              </tr>
              <tr> 
                <td align="center"><input type="submit" name="Submit" value="Upload Photos" /></td>
              </tr>
            </table>
    </td>
    </form>
    </tr>
    </table>

    And...


    PHP Code:
    <?php

     

    $path1
    "uploads/".$HTTP_POST_FILES['ufile']['name'][0];
    $path2"uploads/".$HTTP_POST_FILES['ufile']['name'][1];
    $path3"uploads/".$HTTP_POST_FILES['ufile']['name'][2];

    $target_path $target_path rawurlencode$_POST['lastname']);

    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);

    echo 
    "File Name :".$HTTP_POST_FILES['ufile']['name'][0]."<BR/>";
    echo 
    "File Size :".$HTTP_POST_FILES['ufile']['size'][0]."<BR/>";
    echo 
    "File Type :".$HTTP_POST_FILES['ufile']['type'][0]."<BR/>";
    echo 
    "<img src=\"$path1\" width=\"75\" height=\"75\">";
    echo 
    "<P>";

    echo 
    "File Name :".$HTTP_POST_FILES['ufile']['name'][1]."<BR/>";
    echo 
    "File Size :".$HTTP_POST_FILES['ufile']['size'][1]."<BR/>";
    echo 
    "File Type :".$HTTP_POST_FILES['ufile']['type'][1]."<BR/>";
    echo 
    "<img src=\"$path2\" width=\"75\" height=\"75\">";
    echo 
    "<P>";

    echo 
    "File Name :".$HTTP_POST_FILES['ufile']['name'][2]."<BR/>";
    echo 
    "File Size :".$HTTP_POST_FILES['ufile']['size'][2]."<BR/>";
    echo 
    "File Type :".$HTTP_POST_FILES['ufile']['type'][2]."<BR/>";
    echo 
    "<img src=\"$path3\" width=\"75\" height=\"75\">";


    $filesize1=$HTTP_POST_FILES['ufile']['size'][0];
    $filesize2=$HTTP_POST_FILES['ufile']['size'][1];
    $filesize3=$HTTP_POST_FILES['ufile']['size'][2];


    if(
    $filesize1 && $filesize2 && $filesize3 != 0)
    {
    echo 
    "<P>We have recieved your files";
    }

    else {
    echo 
    "ERROR.....";
    }


    if(
    $filesize1==0) {
    echo 
    "There is an error with your first file";
    echo 
    "<BR />";
    }

    if(
    $filesize2==0) {
    echo 
    "There is an error with your second file";
    echo 
    "<BR />";
    }

    if(
    $filesize3==0) {
    echo 
    "There is an error with your third file";
    echo 
    "<BR />";
    }

    ?>


    Is there any way to take the text typed into the 'lastname' textbox and rename the uploaded files to have their last name at the beginning of the file names?

    Thanks in advance.

  • #2
    Regular Coder sea4me's Avatar
    Join Date
    Jan 2009
    Location
    Damn, I don't know...
    Posts
    390
    Thanks
    11
    Thanked 28 Times in 27 Posts
    Try this:

    PHP Code:
    <?php 
    $lastname 
    $_POST['lastname'];

    //do some checking of the last name HERE!!!

    $separator "_"// the files will have a separator between the last name and the upload name

    $path1"uploads/".$lastname1.$separator.$HTTP_POST_FILES['ufile']['name'][0]; 
    $path2"uploads/".$lastname2.$separator.$HTTP_POST_FILES['ufile']['name'][1]; 
    $path3"uploads/".$lastname3.$separator.$HTTP_POST_FILES['ufile']['name'][2]; 

    $target_path $target_path rawurlencode$_POST['lastname']); 

    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); 

    echo 
    "File Name :".$HTTP_POST_FILES['ufile']['name'][0]."<BR/>"
    echo 
    "File Size :".$HTTP_POST_FILES['ufile']['size'][0]."<BR/>"
    echo 
    "File Type :".$HTTP_POST_FILES['ufile']['type'][0]."<BR/>"
    echo 
    "<img src=\"$path1\" width=\"75\" height=\"75\">"
    echo 
    "<P>"

    echo 
    "File Name :".$HTTP_POST_FILES['ufile']['name'][1]."<BR/>"
    echo 
    "File Size :".$HTTP_POST_FILES['ufile']['size'][1]."<BR/>"
    echo 
    "File Type :".$HTTP_POST_FILES['ufile']['type'][1]."<BR/>"
    echo 
    "<img src=\"$path2\" width=\"75\" height=\"75\">"
    echo 
    "<P>"

    echo 
    "File Name :".$HTTP_POST_FILES['ufile']['name'][2]."<BR/>"
    echo 
    "File Size :".$HTTP_POST_FILES['ufile']['size'][2]."<BR/>"
    echo 
    "File Type :".$HTTP_POST_FILES['ufile']['type'][2]."<BR/>"
    echo 
    "<img src=\"$path3\" width=\"75\" height=\"75\">"


    $filesize1=$HTTP_POST_FILES['ufile']['size'][0]; 
    $filesize2=$HTTP_POST_FILES['ufile']['size'][1]; 
    $filesize3=$HTTP_POST_FILES['ufile']['size'][2]; 


    if(
    $filesize1 && $filesize2 && $filesize3 != 0

    echo 
    "<P>We have recieved your files"


    else { 
    echo 
    "ERROR....."



    if(
    $filesize1==0) { 
    echo 
    "There is an error with your first file"
    echo 
    "<BR />"


    if(
    $filesize2==0) { 
    echo 
    "There is an error with your second file"
    echo 
    "<BR />"


    if(
    $filesize3==0) { 
    echo 
    "There is an error with your third file"
    echo 
    "<BR />"


    ?>

  • Users who have thanked sea4me for this post:

    stephmck990 (03-18-2009)

  • #3
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    7
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Gah, nope. Still just uploading with the file name. :/

    EDIT: Buuuut I got it to work.
    Took the numbers out from behind the lastnames here:
    PHP Code:
    $path1"uploads/".$lastname1.$separator.$HTTP_POST_FILES['ufile']['name'][0]; 
    $path2"uploads/".$lastname2.$separator.$HTTP_POST_FILES['ufile']['name'][1]; 
    $path3"uploads/".$lastname3.$separator.$HTTP_POST_FILES['ufile']['name'][2]; 
    Works wonderfully!

    Thanks so much!
    Last edited by stephmck990; 03-18-2009 at 02:56 PM.

  • #4
    Regular Coder sea4me's Avatar
    Join Date
    Jan 2009
    Location
    Damn, I don't know...
    Posts
    390
    Thanks
    11
    Thanked 28 Times in 27 Posts
    lol I forgot that when I posted

    Glad you got it to work!


  •  

    Tags for this Thread

    Posting Permissions

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