auto rename the uploaded image

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    auto rename the uploaded image

    hello there i am using the class.upload.php and upload.php for the image upload processing it upload with only the name of the file currently so is there any way it will rename autometically of the name like facebook use how to do that ???? anyone can help

    #2
    PHP Code:
    <?php
    // Usage: uploadfile($_FILE['file']['name'],'temp/',$_FILE['file']['tmp_name'])
    function uploadfile($origin$dest$tmp_name)
    {
      
    $origin strtolower(basename($origin));
      
    $fulldest $dest.$origin;
      
    $filename $origin;
      for (
    $i=1file_exists($fulldest); $i++)
      {
       
    $fileext = (strpos($origin,'.')===false?'':'.'.substr(strrchr($origin"."), 1));
       
    $filename substr($origin0strlen($origin)-strlen($fileext)).'['.$i.']'.$fileext;
       
    $fulldest $dest.$newfilename;
      }
     
      if (
    move_uploaded_file($tmp_name$fulldest))
       return 
    $filename;
      return 
    false;
    }
    ?>
    copy/paste from
    upload php auto rename - PHP - Snipplr
    sigpic

    Comment


      #3
      thanx mate!
      mysterio.al - programming is a functional art

      Comment


        #4
        and where do i need to put it didnt understand anythin

        Comment


          #5
          auto rename


          Code:
          <?php 
          // Name of the uploaded file 
          $name = $_FILES['uploadedFile']['name']; 
          // Random 25 chars+nums . . . 
          $your_25_digit_code = substr(md5(rand(0,9999)), 17, 25); 
          // Get the file apart by ., so the 25 chars can be added before the extension 
          $temp_arr = explode(".", $name); 
          // Default it 
          $original_name = ''; 
          // Make sure the file isn't something like 
          // image.something.whatever.hi.hello.what.s.up.png 
          // Minus 2 because it would come out to 
          // (file_name).(random_chars).(extension), 
          // with this it comes out to (file_name)(random_chars).(extension) 
          for ($x = 0; $x < count($temp_arr)-2; $x++) { 
             // Add to it 
             $original_name .= $temp_arr[$x] . '.'; 
          } 
          // The new file name 
          $new_file = $original_name . $temp_arr[$x] . $your_25_digit_code . '.' . $temp_arr[$x+1]; 
          
          $tempFile = $_FILES['uploadedFile']['tmp_name']; 
          $destination = "C:\\ImageHosting\\" . $new_file; 
          copy($tempFile, $destination); 
          
          copy($_FILES['uploadedFile']['tmp_name'], 
             $_FILES['uploadedFile']['name']);
          Last edited by GiLL; 27.10.09, 13:25.
          left wap stuff

          Comment


            #6
            do i need to just include it ????? how to use it in the methos wap scrippt uploading system

            Comment


              #7
              Originally posted by bijaybd View Post
              do i need to just include it ????? how to use it in the methos wap scrippt uploading system

              Email me the file that you use to upload and I will put the rename code in there.

              Comment


                #8
                Here is a detailed description and code to a Image Uploader with auto rename and security to ensure that it is only Images that is being uploaded

                Charlie&#039;s BLOG Blog Archive Image Uploader

                Comment


                  #9
                  the uploader i used its safe with autoresize the image so does your script have this function by this way hackers will not able to hack php sessons

                  Comment

                  Working...
                  X