Re: Renaming File

  •  08-24-2010, 6:37 PM

    Re: Renaming File

    This is the current block of code I am using to store the file in the Absolute File Path of $uploadpath:
    $uploader=new PhpUploader();
    $uploader->Name="myuploader";
    $uploader->SaveDirectory = $uploadpath;
    $uploader->InsertText="Select MP3 to Upload";
    $uploader->AllowedFileExtensions="*.mp3";    
    $uploader->ManualStartUpload=true;
    $uploader->Render();
     
    I have changed it to (per the code above by Eric):
    $uploader=new PhpUploader();
    $uploader->Name="myuploader";
    $uploader->InsertText="Select MP3 to Upload";
    $uploader->AllowedFileExtensions="*.mp3";    
    $uploader->ManualStartUpload=true;
    $uploader->Render();
                                
    //Gets the GUID of the file based on uploader name   
    $fileguid=@$_POST["myuploader"];   
    if($fileguid) {   
       //get the uploaded file based on GUID   
      $mvcfile=$uploader->GetUploadedFile($fileguid);   
      if($mvcfile) {   
        //Gets the name of the file.   
        echo($mvcfile->FileName);   
        //Gets the temp file path.   
        echo($mvcfile->FilePath);   
        //Gets the size of the file.   
        echo($mvcfile->FileSize);
        //echo "eric1".$mvcfile->FileName."eric2";
        $filename = str_replace(' ', '_', $mvcfile->FileName);
        //echo "eric3".$filename;       
        $targetfilepath = $uploadpath . $filename;   
        if( is_file ($targetfilepath) )   
          unlink($targetfilepath);   
        $mvcfile->CopyTo( $targetfilepath );      
        //Moves the uploaded file to a new location.   
        //$mvcfile->MoveTo("/uploads");   
        //Deletes this instance.   
        $mvcfile->Delete();   
      }   
    }   
     
    The file is not going to the specified location of CopyTo. I dont think its leaving the temp location. And the only output Im getting now is the temp location and not the filesize, filename, and file location information I was getting before when the upload was complete.
     
    Thanks for all of the support,
    Jesse
View Complete Thread