Comments (1)
Working through this and adding some error handling seems to have resolved the issue. With the code below in public/legacy/modules/AOS_Products/AOS_Products.php and the vardef changed to image with the same properties as the user image. width, height etc. Ran a repair and rebuild from the admin section.
I can now add images to products! Eureka. Obviously this is a cludge and maybe I have got lucky. I cannot replace the site image though so maybe more of the same in that code. One step at a time.
No additional php errors show up in my Apache or php logs.
Here is my replacement code. I provide no guarantees or warranties and these changes will no doubt be overwritten in any upgrade!
public function save($check_notify = false)
{
global $sugar_config, $mod_strings;
if (isset($_POST['deleteAttachment']) && $_POST['deleteAttachment'] == '1') {
$this->product_image = '';
}
require_once('include/upload_file.php');
$GLOBALS['log']->debug('UPLOADING PRODUCT IMAGE');
if (!empty($_FILES['uploadimage']['name'])) {
$imageFileName = $_FILES['uploadimage']['name'] ?? '';
if (!has_valid_image_extension('AOS_Products Uploaded image file: ' . $imageFileName, $imageFileName)) {
LoggerManager::getLogger()->fatal("AOS_Products save - Invalid image file ext : '$imageFileName'.");
throw new RuntimeException('Invalid request');
}
}
if (!empty($_FILES['uploadimage']['tmp_name'])) {
$uploadErrors = [
UPLOAD_ERR_OK => 'There is no error, the file uploaded with success.',
UPLOAD_ERR_INI_SIZE => 'The uploaded file exceeds the upload_max_filesize directive in php.ini.',
UPLOAD_ERR_FORM_SIZE => 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.',
UPLOAD_ERR_PARTIAL => 'The uploaded file was only partially uploaded.',
UPLOAD_ERR_NO_FILE => 'No file was uploaded.',
UPLOAD_ERR_NO_TMP_DIR => 'Missing a temporary folder. Introduced in PHP 5.0.3.',
UPLOAD_ERR_CANT_WRITE => 'Failed to write file to disk. Introduced in PHP 5.1.0.',
UPLOAD_ERR_EXTENSION => 'A PHP extension stopped the file upload.',
];
$errorCode = $_FILES['uploadimage']['error'];
if ($errorCode !== UPLOAD_ERR_OK) {
die("Upload failed with error: $uploadErrors[$errorCode]");
}
if ($_FILES['uploadimage']['size'] > $sugar_config['upload_maxsize']) {
die($mod_strings['LBL_IMAGE_UPLOAD_FAIL'] . $sugar_config['upload_maxsize']);
}
$prefix_image = $this->getGUID() . '_';
$uploadDir = rtrim($sugar_config['upload_dir'], '/') . '/';
$uploadedFilePath = $uploadDir . $prefix_image . $_FILES['uploadimage']['name'];
if (move_uploaded_file($_FILES['uploadimage']['tmp_name'], $uploadedFilePath)) {
$this->product_image = $sugar_config['site_url'] . '/' . $uploadDir . $prefix_image . $_FILES['uploadimage']['name'];
} else {
die("Failed to move uploaded file to destination.");
}
}
require_once('modules/AOS_Products_Quotes/AOS_Utils.php');
perform_aos_save($this);
return parent::save($check_notify);
}
Maybe someone can take something from the above and fix the issue permanently. I have not looked at why I cannot change the site logo yet.
Tested with mulitple user accounts and works every time to both initially upload an image and also change it.
I hope this demonstrates I am willing to help in any way I can as we really want to start using SuiteCRM but cannot if basic functionality does not work!
I also still have many popups saying undefined or buttons saying undefined and have to guess the function!
Cheers
Tony
from suitecrm-core.
Related Issues (20)
- Diagnostic Tool broken in latest version
- Improve Cache Clear Speed
- Error updating suiteCRM - Leads and Custom Modules HOT 10
- PHP Fatal error: Uncaught RuntimeException: Unable to create the Doctrine Proxy directory on clean install HOT 4
- SCRAM-SHA-1(-PLUS) + SCRAM-SHA-256(-PLUS) + SCRAM-SHA-512(-PLUS) + SCRAM-SHA3-512(-PLUS) supports
- Validation error when editing a case HOT 5
- Custom module with Many-to_One relationship to Users does not show Users in listview HOT 8
- Upload max size error on install HOT 3
- Error 500 on custom module deployment. HOT 2
- Call list shows Related to field incorrectly if containing letters with accents HOT 1
- Error in the Email Field When Required
- Modules no longer state the created by or modified by HOT 3
- Workflows - Calculated Fields - related field won't show up as parameter
- Session Headers Repeated HOT 6
- Descrition field in tasks shows html-entities for special characters HOT 1
- The sub panel cannot display normally HOT 2
- Can't add additional fields to Import Screen in any Module SuiteCRM 8 HOT 2
- Repair & Rebuild does not sync vardefs w/DB SuiteCRM 8 HOT 3
- Unable to Horizontal Scroll Reports in SuiteCRM 8 HOT 1
- Images being displayed in PDF Template but not in PDF File
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from suitecrm-core.