0

hi all i have got a problem with my profile photo upload script after converting to mysqli everytime i go to upload a image i get the following error:

Strict Standards: Only variables should be passed by reference in /home/matureco/public_html/registration2.php on line 11

and the code for that section is as follows:

//For Uploading Profie pic
if(isset($_POST['sub1']))
{
    //$fn   = date('U').$_FILES['userimage']['name'];
    $ext    = end(explode('.',$_FILES['userimage']['name'])); ---THIS LINE---
    $fn     = date('U').".".$ext;
    $ft     = $_FILES['userimage']['type'];
    $fs     = $_FILES['userimage']['size'];
    $ftmp   = $_FILES['userimage']['tmp_name'];
    move_uploaded_file($ftmp, "images/user_images/$fn");
    $thumb  = new Thumbnail('images/user_images/'.$fn);
    $thumb->resize(100,100);
    $thumb->save('images/user_images/smallthumb/'.$fn);
    $thumb1 = new Thumbnail('images/user_images/'.$fn);
    $thumb1->resize(405,540);
    $thumb1->save('images/user_images/bigthumb/'.$fn);

If anyone can give me a idea what it could be ty in advance jan x

2
Contributors
2
Replies
14
Views
1 Year
Discussion Span
Last Post by janicemurby
2

Hi,

The problem is with the end() function. As mentioned in the PHP Manual, "This array is passed by reference because it is modified by the function. This means you must pass it a real variable and not a function returning an array because only actual variables may be passed by reference."

Try replacing line 5 with the following 2 lines to get the file extension using pathinfo()

$path_parts = pathinfo($_FILES['userimage']["name"]);
$ext = $path_parts['extension'];
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.