Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16

Thread: How does copy() function work?

  1. #11
    Join Date
    Sep 2009
    Posts
    24
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    \\ is normal now in HTML5. It acts as \.

    I am sure about this because I tested both versions :

    C:\\wamp\\www\\noyaevofis\\images\\block.png

    and

    C:\wamp\www\noyaevofis\images\block.png

    The explorer takes \\ as \.

    For your last post about $_FILES :

    $_FILES['file_name']['name'] gives only the name and extension of the file but not the full path.

    I spent all my afternoon yesterday for working on $_FILES, but no use.

    I still have hope.

    Nejat

  2. #12
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    557
    Thanks
    8
    Thanked 66 Times in 66 Posts

    Default

    But this is php that's processing the file names. Just leave it as one forwardslash ("/").
    - Josh

  3. #13
    Join Date
    Sep 2009
    Posts
    24
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    Well done, but I have allready tested it also.

  4. #14
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    557
    Thanks
    8
    Thanked 66 Times in 66 Posts

    Default

    OK, but for future reference, it should be left as only one slash.
    - Josh

  5. #15
    Join Date
    Sep 2009
    Posts
    24
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    I can imagine that.

    I have the below lines in my code for this future danger :
    PHP Code:
    $find =chr(92).chr(92) ;
    $logoAdres str_replace($find,chr(92),$logoAdres); 
    Thank you.

    Nejat

  6. #16
    Join Date
    Sep 2009
    Posts
    24
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    I solved the problem today at 10:33 GMT+3.

    It has nothing to do with neither php version nor directory structure/naming.

    It is because of the way that HTML5 handles the POSTed data. Depending on this change in HTML5, the copy() function is handling the source file as : "The source file of the copy() function must be the temp_name not the full path."

    $recName = $_FILES['file_name']['tmp_name']

    This link may give a brief idea about new HTML5 and DOM specs. : http://www.mail-archive.com/whatwg@l.../msg14076.html

    The following final code is tested on 2 different remote servers for IE and FireFox. No errors occured, all the files POSTed were saved into the related directories in both explorers.

    PHP Code:
    <?php 
        
        
    if (!isset($_REQUEST['PLogo'])) {$PLogo="";}  else    $PLogo $_REQUEST['PLogo'] ;
        if (!isset(
    $_REQUEST['Pname'])) {$Pname="";}  else    $Pname $_REQUEST['Pname'] ;
        if (!isset(
    $_REQUEST['action'])) {$action="";}  else    $action $_REQUEST['action'] ;
    ?>
    <form name="Fedit" method="post" enctype="multipart/form-data">

    <table align="center" width="600" cellspacing="2" cellpadding="2" style="border:1px outset #ECECEC;">
      <tr>
        <td bordercolor="#ececec" class="urunkart">Logo : </td>
        <td bordercolor="#ececec">
          <input type="file" name="PLogo" size="70" style="font:7pt verdana;color:#003399" >
        </td>
      </tr>
      <tr>
        <td bordercolor="#ececec" class="urunkart">Name for Logo : </td>
        <td bordercolor="#ececec"><input type="text" name="Pname" size="50" maxlength="255" style="font:7pt verdana;color:#003399"></td>
      </tr>
      <tr>
        <td bordercolor="#ececec" align="center" colspan="2">
          <input    type="submit"    name="action"    value="Save" onmouseover="this.style.cursor='pointer';">
        </td>
      </tr>
    </table>

    </form>
        
    <?     

         $action 
    strtolower(trim($action));

         switch(
    $action)
         {
                   case
    "save" action_update($PLogo,$Pname);   

                break;       
         }


      function 
    action_update($PLogo,$Pname)
      { 
        
    $PLogo $_FILES['PLogo']['tmp_name'] ;

        if (
    $PLogo !=="" )
        {
          
    chdir("./logo");
          if (
    copy($PLogo$Pname)) { echo ("$PLogo saved"); }    else { echo ("$PLogo is not saved");  }
          
    chdir("..");
        }
      }
    ?>
    I thank all of you for your valuable supports.

    Nejat
    Last edited by psikolog; 09-03-2009 at 10:22 AM.

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
  •