25

I also needed something like that recently. Only solution I found to get basename and dirname was using: \Magento\Framework\Filesystem\Io\File protected function someFunction() { /** @var \Magento\Framework\Filesystem\Io\File $fileSystemIo **/ $fileInfo = $this->fileSystemIo->getPathInfo('<absolutePath>'); $basename = $fileInfo['...


3

PHPUnit is installed by Composer, so it's executable is in the /vendor/bin directory. If you want to be able to run that program from anywhere in the command line, you need to add it to your path. Assuming you don't already have another version of phpunit installed globally, there are a couple of ways to do this: If you run export PATH=$PATH:/var/www/...


3

Luckily git lets us see when dirname and basename were forbidden, the reason is clearly, "Added files" Looking at the issue for the ECG project you can see closed issues such as something bad in file_exists? #33, Error Functions #26, something bad in this functions? #17, Context / Explanation for the Rules #12, The use of function iconv() is forbidden #14 ...


2

My suggestion would be to use the Magento/Backup module as an example. The way the download action class is written would be interesting to look at because it also deals with real files to download: public function execute() { /* @var $backup \Magento\Backup\Model\Backup */ $backup = $this->_backupModelFactory->create( $this->...


2

You can use object of SplFileInfo() class may be it will work. $info = new SplFileInfo('/path/to/foo.txt'); var_dump($info->getFilename()) may be it will work. you can also refer this url.


2

From the official documentation: http://devdocs.magento.com/guides/v2.0/architecture/archi_perspectives/components/modules/mod_conventions.html If you want to use a library the recommended location for the component is <your Magento install dir>/lib/<Vendor_Library> If you're having trouble regarding the autoloader I suggest you look up ...


2

You can copy .htaccess file from github repository. Copy it from https://github.com/magento/magento2/blob/2.3-develop/pub/.htaccess If you have already upgraded to version 2.3, you will need .htaccess file of new version i.e 2.3 otherwise download from 2.2.


2

You can try using the read() function defined in that same class: /** * Read a file * * @param string $filename remote file name * @param string|null $destination local file name (optional) * @return mixed */ public function read($filename, $destination = null) { if ($destination === null) { $destination = false; } return $this->...


1

Try following code $directory = $this->filesystem->getDirectoryRead('media'); $fullImagePath = $directory->getAbsolutePath($this->mediaConfig->getMediaPath($product->getThumbnail())); For this, you need to inject below class in your constructor use Magento\Catalog\Model\Product\Media\Config; use Magento\Framework\Filesystem; ...


1

I thought the "Manage Attachments" is a magento core functionality, but it is acutally a extension called Uni_Fileuploader. Thanks to @Haim, for the hint! I changed the function saveAction from: public function saveAction() { $filedata = array(); $uploadedFile = 'uploaded_file'; $_helper = Mage::helper('fileuploader'); if (!empty($_FILES[$...


1

Assuming you are referring to the WYIWYG editor and that you're trying to overwrite an existing image but you don't want the upload to change your image name, you can always the delete the original image first and then upload your new image. Since you first delteed teh original image, when you upload the new image it will keep the filename as intended.


Only top voted, non community-wiki answers of a minimum length are eligible