PHP Image Upload

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Redapple
    New Member
    • Mar 2007
    • 5

    PHP Image Upload

    Goodmorning everybody.

    Im started using PHP yesterday and i was wondering if anybody has a fully non-bug example of a php upload script. I want to learn how to upload a image true PHP with the follow functions:

    - Rename the file once uploaded (Like random name).
    - 2,5 MB Max (I believe php is doing bytes so that will be 2500000)

    Im sorry if this is the wrong forum, But i just want to learn

    Thanks!
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    #2
    if you want to learn why are you asking for a functional fully debugged script? This is not the way it works on a forum. You make an attempt yourself then ask for assistance when you are struggling.
    Anyway your request is rather vague. Upload from where to where?

    Comment

    • Redapple
      New Member
      • Mar 2007
      • 5

      #3
      Sorry, I did not know that, I will keep that in mind.

      I had a script that just uploaded it to images/ but i doesnt have it anymore. Overwrote it with other sample's.

      Comment

      • vssp
        Contributor
        • Jul 2006
        • 268

        #4
        this function copyes a file or folder, it needs another function (ls_a):
        this works perfect.
        ////////////////////////////////////////////////////////
        /// cp function/////////////////////////////////
        ////////////////////////////////////////////////////////
        function cp($wf, $wto){ // it moves $wf to $wto
        mkdir($wto,0777 );
        $arr=ls_a($wf);
        foreach ($arr as $fn){
        if($fn){
        $fl="$wf/$fn";
        $flto="$wto/$fn";
        if(is_dir($fl)) cp($fl,$flto);
        else copy($fl,$flto) ;
        }
        }
        }
        ///////////////////////////////////////////////////
        /// ls_a function////////////////////////
        // This function lists a directory.
        // ANd is needed for the cp function.
        function ls_a($wh){
        if ($handle = opendir($wh)) {
        while (false !== ($file = readdir($handle ))) {
        if ($file != "." && $file != ".." ) {
        if(!$files) $files="$file";
        else $files="$file\n $files";
        }
        }
        closedir($handl e);
        }
        $arr=explode("\ n",$files);
        return $arr;
        }

        Comment

        Working...