Two questions

Last post 05-09-2010, 8:21 PM by cutechat. 3 replies.
Sort Posts: Previous Next
  •  05-08-2010, 2:52 PM 60839

    Two questions

    First of all, really like the script. Best one i found so far.
     
    I used this code (below) to get the filenames, which works well...until i add a:
    $uploader->SaveDirectory="../images/upload";

    Seems it cant find the files if the path is changed...how can I fix this?
     
    Also, is there a way to limit the amount of files?
    Say I only want people to upload 5 files max?
     
    regards,
    P.
     

    $fileguidlist=@$_POST["myuploader"];
    if($fileguidlist)
    {
        $guidlist=explode("/",$fileguidlist);
        
        echo("<div style='font-family:Fixedsys;'>");
        echo("Uploaded ");
        echo(count($guidlist));
        echo(" files:");
        echo("</div>");
        echo("<hr/>");
        
        foreach($guidlist as $fileguid)
        {
            $mvcfile=$uploader->GetUploadedFile($fileguid);
            if($mvcfile)
            {
                echo("<div style='font-family:Fixedsys;border-bottom:dashed 1px gray;padding:6px;'>");
                echo("FileName: ");
                echo($mvcfile->FileName);
                echo("<br/>FileSize: ");
                echo($mvcfile->FileSize." b");
                echo("<br/>FilePath: ");
                echo($mvcfile->FilePath);
                echo("</div>");
    ...
  •  05-08-2010, 6:05 PM 60840 in reply to 60839

    Re: Two questions

    First of all, really like the script. Best one i found so far. 
    I used this code (below) to get the filenames, which works well...until i add a:
    $uploader->SaveDirectory="../images/upload";
    Seems it cant find the files if the path is changed...how can I fix this?
     
    You can try the following code:
    <?php require_once "phpuploader/include_phpuploader.php" ?>
    <?php session_start(); ?> 
    <html>   
    <body>   
            <form id="form1" method="POST">   
                <?php   
                    $uploader=new PhpUploader();   
                    $uploader->Name="myuploader";    
                    $uploader->Render();   
                ?>   
            </form>   
    <?php   
    //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);    
               
            //Copys the uploaded file to a new location.   
            $mvcfile->CopyTo("/savefiles");   
            //Moves the uploaded file to a new location.   
            //$mvcfile->MoveTo("/uploads");   
            //Deletes this instance.   
            $mvcfile->Delete();   
        }   
    }   
    ?>  
    </body>   
    </html>
     
    Issue 2, Say I only want people to upload 5 files max?
    Please use property $MaxFilesLimit, set it to 5
     
    Regards,
    Eric
     
     
     
     
  •  05-09-2010, 2:35 PM 60845 in reply to 60840

    Re: Two questions

    Thanks for your reply, erik.
     
    Im still getting the same results no matter what I try.
     
    I also tried the Show Attachments Table demo...and added :
    $uploader->SaveDirectory="../images/upload"; (path must be relative, otherwise I get an error)
    The images get uploaded to it...but table stays empty.
    If I delete the SaveDirectory it works fine.

     
  •  05-09-2010, 8:21 PM 60847 in reply to 60845

    Re: Two questions

    Hi,
     
    $uploader->GetUploadedFile($fileguid);    is for getting temp file. xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx.filename.ext.resx
     
    If you use SaveDirectory , the temp file will move to destination folder, and uploader will not able to maintain it again.
     
    So if you use any way to move the temp file , you need maintain the list by your way , but not GetUploadedFile
     
    Regards,
    Terry
View as RSS news feed in XML