XF 2.0 Imagick a file inside data

AndrewSimm

Well-known member
I have a news mod that allows a staff member to select a news image to associate with each article. The news image is than resized into 3 different images and then saved to the correct folder. All of this works fine. The problem is I have to put the full filepath in php and can not use "data://". Also for what it's worth, only staff members can post news, so no reasons "that I know of" to use the attachment system.

PHP:
        $image_name = $_FILES['image']['name'];
        $filePath = '/home/***/public_html/preview/data/CIS/News/';
        $dataFile = 'data://CIS/News/' . $thread_id . '/' . $post_id . '/' . $image_name;
        $dataFileIM = $filePath . $thread_id . '/' . $post_id . '/' . $image_name;
        $dataFileXL = $filePath . $thread_id . '/' . $post_id . '/xl-' . $image_name;
        $dataFileL = $filePath . $thread_id . '/' . $post_id . '/l-' . $image_name;
        $dataFileS = $filePath . $thread_id . '/' . $post_id . '/s-' . $image_name;
        $image = $_FILES['image']['tmp_name'];

// Copy image to correct path
\XF\Util\File::copyFileToAbstractedPath($image, $dataFile);

// Resize images to correct size
$imagickXL = new \Imagick($dataFileIM);
$imagickXL->resizeImage(1180,500,true,\Imagick::FILTER_LANCZOS,1);
$imagickXL->writeImage($dataFileXL);

$imagickL = new \Imagick($dataFileIM);
$imagickL->resizeImage(990,300,true,\Imagick::FILTER_LANCZOS,1);
$imagickL->writeImage($dataFileL);

$imagickS = new \Imagick($dataFileIM);
$imagickS->resizeImage(498,185,true,\Imagick::FILTER_LANCZOS,1);
$imagickS->writeImage($dataFileS);
 
The problem is I have to put the full filepath in php and can not use "data://".
These aren't real file paths. They're not using stream wrappers, for example. They're only meaningful within calls to the underlying Flysystem library that we use. Hence, you'll see various places where we move back and forth between local file paths and where ever the abstracted path points to (as you used in that code).
 
Top Bottom