deleting a image file yii - image

can any one pls tell me how to delete an image file and directory in yii
I have tried unlink but its not working.(the path is correct but its not deleting) but getting the error No such file or directory
unlink(Yii::app()->request->baseUrl.'/uploads/'.$model->file_id.'/'.$fileModel->file_name.$fileModel->extension);
and I also need to delete a directory in yii framework.the path is
correct but its not deleting
rmdir(Yii::app()->request->baseUrl.'/uploads/'.$model->file_id);
This is not working either, but getting the error No such file or directory.

Try:
unlink(getcwd().'/uploads/'.$model->file_id.'/'.$fileModel->file_name.$fileModel->extension);
getcwd() gets the current working directory. The docs for it are here

Instead of
Yii::app()->request->baseUrl
Try
Yii::app()->basePath

I have never used Yii's earlier versions.
For Yii2: unlink(Yii::$app->basePath.'/directory_path/'.$filename);

we can use this as well
unlink($file->getFullPath());

Related

storing a file to a symlink in laravel 9

I'm trying to get an image from the web and store it locally in my 'app/library' folder using Laravel 9. After battling for an hour with get_file_contents, I finally discovered guzzler and the file is fetched properly. Now I'm trying to save it using the following command.
$stored = Storage::put(storage_path('app/library').'/'.$filename, $content)'
$stored shows as '1', which leads me to think that it's worked, but the file is not in my app/library folder. Nor can I find any file with the correct name anywhere in my project.
Is there something wrong with my command?
Run the storage:link command.
See https://laravel.com/docs/9.x/filesystem#the-public-disk
Thanks to lagbox for the answer. I was overthinking it and didn't need 'storage_path()'. The following worked.
$stored = Storage::put('library/'.$filename, $content)'

Can't run an old laravel project

so i've beein struggling with an old laravel project from 2018 that i can't seen to run. The probem is that the project i splittedinto two folders not a classic laravel one, there's an other one named "httpdocs" and the index.php is there, so i managed to install everything and running the migrations, but noti can't run the website ? idk why it said:
Warning: require(C:\xampp\htdocs\httpdocs/../daddyshop_app/vendor/autoload.php): failed to open stream: No such file or directory in C:\xampp\htdocs\httpdocs\index.php on line 24
the autoload.php file exists
I think this part is wired, see / and \ on the require:
require(C:\xampp\htdocs\httpdocs/../daddyshop_app/vendor/autoload.php)
Maybe you are setting wrongly the folder structure, or in the index.php file, you are searching in the wrong path.
For example, try checking paths are correct:
Maybe /../../laravel-app or ../.. or /../laravel-app.
You get the point, make sure paths are correct.

Laravel pdf issue: failed to open stream: No such file or directory by using barryvdh/laravel-dompdf package

I am update composer and use barryvdh/laravel-dompdf package.
the problem is when i click the button it show me error like image below:-
Is that anyway to change the folder path? or am I missing code to modify path to download the pdf file?
You need to run this command:
php artisan vendor:publish
Then, try to create a fonts directory in the storage directory.
i.e. storage/app/fonts. Also, remember to make it writable.
For maximum execution time of 30 seconds exceeded, this is not laravel related issue but it's about php configuration issue. Please see this and fix it: http://php.net/manual/en/info.configuration.php#ini.max-execution-time
You can also see this answer: https://stackoverflow.com/a/30290770/6000629
Hope this will helps you!
Try this:
$pdf = PDF::loadView('pdf/personalpdf', compact('user','result'))->setOptions(['defaultFont' => 'sans-serif']);
It worked for me, I didn't make any file/folder
Just remove the reference to css external file in your cart.placeOrder.blade
Note: This directory must exist and be writable by the webserver process.
under the config file thats what it say: therefore you should create the fonts directory inside the storage.
"font_cache" => storage_path('fonts/'),

Laravel 5.3 FileNotFoundException

I am uploading an image to local storage as
$path = $request->image->store('images');
Image gets stored in storage/app/images/name.extension
However my problem is showing this image to the user, I am getting file not found exception
I tried, asset, Storage:get, Storage::url and etc.
Any solutions?
You can create a symbolic link to the storage/app/images/ from the public directory.
ln -s storage/images public/images
Try this one
Storage::get('/images/'.$filename);
or
Storage::get('/app/images/'.$filename);
Mistake was I was storing files in storage/app/images directory instead of storage/app/public/images and finally I retrieved using
asset('storage/'.$image-name)

no file uploaded error in magento

I have upgraded my Magento version from 1.4.0.1 to 1.7.0.2.
Now I tried to upload a theme package using upload package file in Magento Connect Manager. It shows an error 'No file was uploaded'.
Please get me a solution.
Try using the Version 2.0 from the dropdown on the extensionpage on magento-connect, that should work.
The No file was uploaded error is return when:
The form key is invalid
$_FILES doesn't exist
$_FILES['file'] is empty
I had the same issue and managed to fix it by commenting out the rewrite instructions in my main .htaccess file in Magento's root folder. Don't forget to add those instructions back after you finished installing your module.
I suggest you keep a .htaccess.magento-connect file for when you want to use Magento Connect along with your regular .htaccess file, and switch between the two.

Resources