# Picture upload not working

**URL:** <https://forum.infinityfree.com/t/picture-upload-not-working/34082>\
**Category:** Hosting Support\
**Created:** [August 7, 2020, 2:25am UTC](https://forum.infinityfree.com/t/picture-upload-not-working/34082 "2020-08-07T02:25:34Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon23157071](https://forum.infinityfree.com/letter_avatar/anon23157071/32/5_5575768a8748004e209b776fc1b2916d.png) [@anon23157071](https://forum.infinityfree.com/u/anon23157071)\
**Post date:** [August 7, 2020, 2:25am UTC](https://forum.infinityfree.com/t/picture-upload-not-working/34082/1 "2020-08-07T02:25:34Z")

</div>

epiz\_26217215 mediconn.services

**Warning** : A non-numeric value encountered in **/home/vol7\_2/epizy.com/epiz\_26217215/htdocs/processUploadLogo/index.php** on line **94**  
There was a problem uploading Display Picture.

---

<div class="post-metadata">

**Author:** ![JavesPotato](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/javespotato/32/53167_2.png) [@JavesPotato](https://forum.infinityfree.com/u/JavesPotato)\
**Post date:** [August 7, 2020, 3:49am UTC](https://forum.infinityfree.com/t/picture-upload-not-working/34082/2 "2020-08-07T03:49:11Z")

</div>

Can you give us the code rather than only giving generic, broad error?

It must be on your code.

---

<div class="post-metadata">

**Author:** ![anon23157071](https://forum.infinityfree.com/letter_avatar/anon23157071/32/5_5575768a8748004e209b776fc1b2916d.png) [@anon23157071](https://forum.infinityfree.com/u/anon23157071)\
**Post date:** [August 7, 2020, 2:42pm UTC](https://forum.infinityfree.com/t/picture-upload-not-working/34082/3 "2020-08-07T14:42:49Z")

</div>

The code worked well on localhost

---

<div class="post-metadata">

**Author:** ![anon81626513](https://forum.infinityfree.com/letter_avatar/anon81626513/32/5_5575768a8748004e209b776fc1b2916d.png) [@anon81626513](https://forum.infinityfree.com/u/anon81626513)\
**Post date:** [August 7, 2020, 2:58pm UTC](https://forum.infinityfree.com/t/picture-upload-not-working/34082/4 "2020-08-07T14:58:30Z")

</div>

Plase share your code, localhost and hosting work very different

---

<div class="post-metadata">

**Author:** ![anon23157071](https://forum.infinityfree.com/letter_avatar/anon23157071/32/5_5575768a8748004e209b776fc1b2916d.png) [@anon23157071](https://forum.infinityfree.com/u/anon23157071)\
**Post date:** [August 7, 2020, 11:02pm UTC](https://forum.infinityfree.com/t/picture-upload-not-working/34082/5 "2020-08-07T23:02:41Z")

</div>

[http://mediconn.services/processUploadLogo/index.php](http://mediconn.services/processUploadLogo/index.php)  
Line 88 throws the error.  
Please help

---

<div class="post-metadata">

**Author:** ![anon23157071](https://forum.infinityfree.com/letter_avatar/anon23157071/32/5_5575768a8748004e209b776fc1b2916d.png) [@anon23157071](https://forum.infinityfree.com/u/anon23157071)\
**Post date:** [August 7, 2020, 11:05pm UTC](https://forum.infinityfree.com/t/picture-upload-not-working/34082/6 "2020-08-07T23:05:17Z")

</div>

Below is the code, Line 88 throws the error:

```auto
<?php

session_start();
include('../classes/Log_Errors.php');
include('../classes/PMediconnAuth.php');
include('../classes/User.php');
require_once('../classes/current_page.php');
require_once('../classes/Security.php');
require_once('../classes/Validate_input_elements.php');

function getExtension($str) {
    $i = strrpos($str, ".");
    if (!$i) {
        return "";
    }
    $l = strlen($str) - $i;
    $ext = substr($str, $i + 1, $l);
    return $ext;
}

function check_for_emptyString($string) {
    if (empty($string)) {
        return TRUE;
    } else {
        return FALSE;
    }
}

if (!isset($_SESSION['userRole']) || ($_SESSION['userRole'] != 'Mediconn Admin' && $_SESSION['userRole'] != 'Institution Admin' && $_SESSION['userRole'] != 'Hospital Admin' )) {
    session_unset();
    session_destroy();
    $errorno = 'You may be unauthorized to view the requested resource!';
    if (headers_sent()) {
        die("Please click on this : <a href=http://mediconn.services/?msp=$errorno>LINK</a>");
    } else {
        header("location: http://mediconn.services/?msp=$errorno");
        exit();
    }
} else {
    $userName = htmlentities($_SESSION['username'], ENT_QUOTES, 'UTF-8');
}
If (isset($_POST['uploadLogoToken']) && ($_SESSION['uploadLogoToken'] === $_POST['uploadLogoToken'])) {
    $institutionName = trim(htmlentities($_POST['institution'], ENT_QUOTES, 'UTF-8'));
    $user = new User(); //instantiate User Object
    $destpath = "Uploads".DIRECTORY_SEPARATOR;
    //Upload Inside view here
    if (isset($_FILES["logoUpload"]["name"])) {
        $passport_upload_errors = 0;
        //$valid_iv_name = Validate_inputs::Validate_image_name($_FILES["inside_view"]["name"]);
        //if($valid_iv_name === TRUE){
        $passport_upload_name = $_FILES["logoUpload"]["name"];
        $origName = htmlentities($passport_upload_name, ENT_QUOTES, 'UTF-8');
        //}
        $actual_size = $_FILES["logoUpload"]["size"];
        $source = $_FILES["logoUpload"]["tmp_name"];
        // get the extension of the file in a lower case format
        $extension = getExtension($_FILES["logoUpload"]["name"]);
        $extension = strtolower($extension);
        // get the size of the image in bytes
        // $_FILES[\'image\'][\'tmp_name\'] is the temporary filename of the file in which
        //the uploaded file was stored on the server
        $size = getimagesize($_FILES["logoUpload"]["tmp_name"]);
        $sizekb = $_FILES["logoUpload"]["size"];
        // if it is not a known extension, we will suppose it is an error, print an error message and will not upload the file, otherwise we continue
        if ($size['mime'] != 'image/jpeg' && $size['mime'] != 'image/png' && $size['mime'] != 'image/jpg') {
            $errorno = 'Unknown extension for ' . $html['passport_upload_name'] . ' in Passport Upload field !';
            $passport_upload_errors = 1;
        } elseif ($sizekb > 10240000) {
            $errorno = 'You exceeded the maximum size limit for ' . $html['passport_upload_name'] . ' in Passport Upload field !';
            $passport_upload_errors = 1;
        } elseif ($sizekb < 5024) {
            $errorno = 'You exceeded the minimum size limit for ' . $html['passport_upload_name'] . ' in Passport Upload field !';
            $passport_upload_errors = 1;
        } elseif ($_FILES["passportUpload"]["error"] > 0) {
            $errorno = 'Error in ' . $html['passport_upload_name'] . ' in Passport Upload field !';
            $passport_upload_errors = 1;
        }
        //upload here
        if ($passport_upload_errors == 0) {
            //$filename = time() . $_SERVER['REMOTE_ADDR'].'.'.$extension;
            //sudo chown -R www-data:www-data /home/vol7_2/epizy.com/epiz_26217215/htdocs/processUploadLogo/
            //sudo chmod 755 /home/vol7_2/epizy.com/epiz_26217215/htdocs/processUploadLogo/
            $new_iv_name = mt_rand() . mt_rand() . mt_rand() . mt_rand() . mt_rand() . '.' . $extension;
            //$new_iv_name .= Validate_inputs::Validate_Filename_for_DB($new_iv_name);
            $newname = "Uploads/" . $new_iv_name;
            //move_uploaded_file($source, $destpath . $new_iv_name) ;
            try {
                if (!@move_uploaded_file($source, $destpath . $new_iv_name)) {
                    //flag failure
                    //$pass_copy = 'failed';
                    throw new Exception("There was a problem uploading Display Picture");
                }
            } catch (exception $e) {
                $errorno += "; " . $e->getMessage();
                Log_Errors::Log_error_msg($e->getCode(), $e->getMessage(), $e->getFile(), $e->getLine());
                echo $e->getMessage().' on the line, '.$e->getLine().' on the file, '.$e->getFile();
                //stop script
                exit();
            }
            try {
                if (filesize($destpath . $new_iv_name) != $actual_size) {
                    //$dest_size = 'not_equal';
                    throw new Exception('There was a problem uploading complete Display Picture');
                }
            } catch (exception $e) {
                //remove the room image completely from the upload folder
                unlink($destpath . $new_iv_name);
                //print user friendly error msg
                //echo $e->getMessage();
                $errorno += $e->getMessage();
                //log error msg
                Log_Errors::Log_error_msg($e->getCode(), $e->getMessage(), $e->getFile(), $e->getLine());
                //stop script
                exit();
            }
        }
        $user->saveLogoUpload($userName, $institutionName, $origName, $new_iv_name);
        unset($_SESSION['uploadLogoToken']);
    }$errorno = 'You succeeded in uploading a logo for the institution, ' . $institutionName . ', on the platform.';
    if (headers_sent()) {
        die("Please click on this : <a href=http://mediconn.services/?msp=$errorno>LINK</a>");
    } else {
        header("location: http://mediconn.services/?msp=$errorno");
        exit();
    }
} else {
    session_unset();
    session_destroy();
    $errorno = 'you may be unauthorized to view the reqquested page';
    header("location: http://mediconn.services/register/?msp=$errorno");
    exit;
}

```

---

<div class="post-metadata">

**Author:** ![anon99413185](https://forum.infinityfree.com/letter_avatar/anon99413185/32/5_5575768a8748004e209b776fc1b2916d.png) [@anon99413185](https://forum.infinityfree.com/u/anon99413185)\
**Post date:** [August 8, 2020, 2:56am UTC](https://forum.infinityfree.com/t/picture-upload-not-working/34082/7 "2020-08-08T02:56:39Z")

</div>

I think this isn’t hosting support.

Line 88 from code above is:

```auto
if (!@move_uploaded_file($source, $destpath . $new_iv_name)) {
//flag failure
//$pass_copy = ‘failed’;
throw new Exception(“There was a problem uploading Display Picture”);
}

```

There are something wrong with your `move_uploaded_file()` function.  
Find that function from your included/required files.

Or did you try to upload the picture from HTTPS URL?  
Maybe related to this problem:

> [@PHPMailer Suddenly Stopped working](https://forum.infinityfree.com/t/phpmailer-suddenly-stopped-working/33986/4):
>
> We upgraded OpenSSL on our servers a few days ago. This may have resulted in SSL for SMTP breaking. I’m going to do some investigation into this. The provided SMTPOptions are a good workaround until then. Please note that you should AVOID such SMTPOptions as much as possible, because fixing SSL issues by disabling most SSL security features is NOT a good solution.

& you are using `file_get_contents()` function like this:

> [@File\_get\_contents(): SSL error](https://forum.infinityfree.com/t/file-get-contents-ssl-error/34106):
>
> Hello There is new error I get each time I uses file\_get\_contents() for any SSL URL My username epiz\_24927975 Website url [http://yanivhatulim.rf.gd/test.php](http://yanivhatulim.rf.gd/test.php)Error Message Warning : file\_get\_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:1416F086:SSL routines:tls\_process\_server\_certificate:certificate verify failed in /home/vol8\_7/epizy.com/epiz\_24927975/htdocs/test.php on line 3 Warning : file\_get\_contents(): Failed to enable crypto in /home/vol8\_7/epizy.…

---

<div class="post-metadata">

**Author:** ![Admin](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/admin/32/36437_2.png) [@Admin](https://forum.infinityfree.com/u/Admin)\
**Post date:** [August 8, 2020, 5:39pm UTC](https://forum.infinityfree.com/t/picture-upload-not-working/34082/8 "2020-08-08T17:39:06Z")

</div>

Looking on line 94, it seems quite obvious why it doesn’t work. This is what’s on that line:

```auto
$errorno += "; " . $e->getMessage();

```

The `+=` operator is used to add numbers (integers or floats). But you’re adding non numerical string data to a number. The variable `$errorno` also implies it should be a number, so I don’t see how this should work.

Which PHP version do you run on your own computer? Our servers use PHP 7.4 by default. If you use an older PHP version, the data type conversion may work slightly differently and allow this to run without error.

But that doesn’t fix the issue with `move_uploaded_file`. You may want to use the `error_get_last()` to retrieve the error from the function call so you can see why it fails.

---

<div class="post-metadata">

**Author:** ![system](https://infinityfree-forum-uploads.s3.dualstack.eu-central-1.amazonaws.com/original/3X/b/0/b024fd3fa88bae093c9576e55c2c94e33f890206.svg) [@system](https://forum.infinityfree.com/u/system)\
**Post date:** [August 23, 2020, 5:39pm UTC](https://forum.infinityfree.com/t/picture-upload-not-working/34082/9 "2020-08-23T17:39:11Z")

</div>

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.
