www.webdeveloper.com
Results 1 to 2 of 2

Thread: FileUpload() Error

Hybrid View

  1. #1
    Join Date
    Jun 2013
    Posts
    1

    Exclamation FileUpload() Error

    Hello Friends,

    I am getting the following error:

    Strict Standards: Only variables should be passed by reference in the function FileUpload()

    The function FileUpload() as follows:

    PHP Code:
    function FileUpload($FieldName 'File' ,$UploadFolder '' $allowed_ext=''){        
        if(
    $FieldName != ""){    
            
    $name $_FILES[$FieldName]['name']; 
            
    $ext strtolower(end(explode(".",$name)));
            
    $type $_FILES[$FieldName]['type'];
            
    $size $_FILES[$FieldName]['size']; // in bytes
            
    $size = ($size/1024)/1024// in mb
            
    $error $_FILES[$FieldName]['error'];
            
    $tmp_name $_FILES[$FieldName]['tmp_name'];
            
            
    //$allowed_type = array('images/jpeg', 'images/pjpeg' , 'images/gif' , 'images/bmp' , 'images/jpg');
            
            
    $allowed_ext = array('jpeg' 'jpg' 'bmp' 'gif' 'doc' 'docx' 'pdf' 'txt' 'zip' 'rar');
            
            
    $UploadDir '';
            
            if(
    $name != ''){
            
            if(
    $error == ''){
                
    //in_array($type , $allowed_type) &&
                
    if(in_array($ext $allowed_ext)){
                    if(
    $size <=8){
                        if(
    $UploadFolder != ""){
                            if(!
    is_dir($UploadFolder)){
                                
    mkdir($UploadFolder 0777);    
                            }
                            
    $UploadDir $UploadFolder;
                        }else{
                            
    $UploadDir 'uploads';
                        }
                        
    $new_filename time()."--".$name;
                        
    $IsUploaded move_uploaded_file($tmp_name $UploadDir."/".$new_filename);
                        if(
    $IsUploaded){
                            return 
    $UploadDir."/".$new_filename;
                        }else{                    
                            
    $_SESSION['UploadError'] = "File can not be uploaded , please try again.";
                            return 
    false;
                        }
                    }else{
                        
    $_SESSION['UploadError'] = "File size must be under 8mb";                
                        return 
    false;
                    }
                }else{            
                    
    $_SESSION['UploadError'] = "Only ".implode(", ",$allowed_ext)." files are allowed";    
                    return 
    false;
                }
            }else{
                
                
    $_SESSION['UploadError'] = $error;
                return 
    false;
            }
            }else{        
                
    $_SESSION['UploadError'] = 'You have not select any file to upload.';
                return 
    false;
            }
        }    

    Kindly help me to solve this error.

    Thank you

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,359
    I don't see anything obvious. The error message should give you the exact file and line number where it decided it had run into a problem. Can you get that info and help us to know exactly which line is the problem? (I'm guessing it's at the line of code that calls that function, not in the function itself -- but that's only a guess right now.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles