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.
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.
Can you give us the code rather than only giving generic, broad error?
It must be on your code.
The code worked well on localhost
Plase share your code, localhost and hosting work very different
Below is the code, Line 88 throws the error:
<?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;
}
I think this isn’t hosting support.
Line 88 from code above is:
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:
& you are using file_get_contents()
function like this:
Looking on line 94, it seems quite obvious why it doesn’t work. This is what’s on that line:
$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.
This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.