File not downloading laravel 5.6 - laravel

I've read other questions and implemented answers but haven't had any success.
Here's the error:
files in database, and locally:
here's my form:
here's my file-controller:
The flow is I upload a file, it is stored into the database, and locally, the files locally work properly. I implemented the download attribute and was able to get actual files, but those files and that process was scrapped because the files downloaded, while they had the correct names and mime types, the file had a error like "could not open file".
I am primarily using the download method in the filecontroller which you can see above, I used some ideas for getting the actual path to the file, as that seems to be the issue, but even using the storage_path method I'm getting this error.
Thanks!

I didn't understand the pathing for filestorage enough, and was therefor obviously getting the incorrect paths to the file being stored.
For example, the storage_path method returns the path to storage, I thought it was going to give me the exact path to the file. Once figuring this out I was able to navigate and fix my issues.
filecontroller
line 52: storeAs was storing to a redundant path, i made it as '/upload'/
filescontroller#download
return response()->download(storage_path("app/upload/{$file}"));
following the paths where files were being saved locally, I was able to fix this issue.

Related

Unexpected Behavior in Laravel 7 with Storage::put() and fopen()

I am working on a solo project where admin users will be able to manage Virtual Machines via a web application run on laravel 7. I am currently creating the creation controller which requires uploading large files (.ovas). I am trying to use streams (I think) in a store method.
Specifically, a view has a form with a standard file inclusion that sends the request to the controller. The form gets validated and then I try to move the file into storage as such:
$data = $this->validator($request);
Storage::put('files', fopen($data['file'], 'r+'));
Where $data['file'] is the uploaded file. I can see the file being uploaded locally (while monitoring hdd usage), but after it is sent, laravel returns the following error
fopen(/var/www/html/devel/ocl/storage/app/files): failed to open stream: Is a directory
The error seems pretty obvious, so I was curious and decided to return the fopen() call before storage to see if I could invoke the same error by changing the method to:
$data = $this->validator($request);
return var_dump(fopen($data['file'], 'r+'));
However, no error is invoked and I get resource(8) of type (stream) as expected (I think). The tmp resource disappears and no errors are thrown. I am a bit baffled on why this is occurring as I would assume that function call resolves before the storage. I feel like I'm missing something fundamental with PHP/laravel and cannot think of how to continue to explore the issue.
Why does the first call to fopen() seem to see $data['file'] as a path, but the second call to just fopen() work as intended? I am hoping the answer can help remedy the issue.
Thanks!

Laravel 4 - can't access images in public folder

I have a strange behaviour from Laravel. I just copied the website to a new hoster. Everything is working quite fine but one thing: I can't access the images in my public folder. If I try to open an image on my own with "domain.com/img/Ausfahrten/42.png i get the following error:
error image loading
The folder structure on my server looks like this:
enter image description here
What method can't laravel find and how can I resolve this? I've already checked file permissions on the server, everything's fine there.
Laravel throw that error when it cannot find the file. Try to access to another directory without Uppercase letter in its path name.

Fatal error: Class 'Mage_Sales_Model_Order' not found in ....core/Mage/Reports/Model/Resource/Order/Collection.php on line 456

I was installing magento 1.9.1 on my server everything went fine but after installation when i click on Go to Backend and give my username and password to login to Admin Panel it gives the following error:
Fatal error: Class 'Mage_Sales_Model_Order' not found in
/home2/siatel/public_html/4ebay/app/code/core/Mage/Reports/Model/Resource/Order/Collection.php
on line 456
Though my frontend side of website is working perfectly ... Please help.
I can see my admin log-in page. Error comes only when I give username and pass and hit continue...
Without more information, it sounds like you're missing your
app/code/core/Mage/Sales/Model/Order.php
file. It seems like you're missing a lot of different files as well. I'd diff your installation vs. the contents of a standard tar archive.
Your error shows like this
Fatal error: Class 'Mage_Shipping_Helper_Data' not found in
/home2/siatel/public_html/4ebay/app/Mage.php on line 547
see the portion 'Mage_Shipping_Helper_Data' not found. It means Magento is looking for a helper class file and it couldnt find it. Magento will look for this file in app/code/core/Mage/Shipping/Helper/Data.php.
I will give you some hint on how this file path came from. First of all magento core files lies in the location app/code/core/. Then missing class name (in this case Mage_Shipping_Helper_Data) will converted as Mage/Shipping/Helper/Data.php. Then this will append to the core codePool directory path. That is app/code/core/Mage/Shipping/Helper/Data.php
For every file, magento assigns path as like this. Please note that, you need to attach .php part to the last keyword. Also you need to copy the exact same data of that file (take into consider the version). It means it need to have a 'Magento way' class name and so on

The file name you submitted already exists on the server

Most of the time I upload an image I get an error which says "The file name you submitted already exists on the server". I am using codeigniter version 2.1.0.
Please help regarding how can I fix this.
Thanks
Please enable encrypt_name, find more here
$config['encrypt_name'] = TRUE;
By this line you are telling codeigniter to create (pseudo) random filname for your file therefore your file is going to be unique (in name matter).
Furthermore you can create such a system that uploads files in folders, consider following folder structure:
/files/pictures/<date_of_upload>/<random_string>_big.jpg
/files/pictures/<date_of_upload>/<random_string>_thumb.jpg

upload huge numbers of files to blob

Do you know best way to upload too many files to Azure Blob container?
I am currently do something to upload multiple files to Azure blob storage. The number of files may be huge, like 30,000 or more(each file could be sized of 10KB~1MB). Firstly, I have a list of files locations, then I would use Parallel.Foreach to upload the files. code snippet like this:
`List locations=...
Parallel.Foreach(locations, location=>
{
...
UploadFromStream(...);
...
});`
The codes run to inconsistence results.
Sometimes it runs well, I can see all files uploaded to the Azure blob container.
Sometimes, I will got exceptions like this:
Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature., Inner Exception: The remote server returned an error: (403) Forbidden
Sometimes, I got a timeout exception.
I have worked against the issue for several days, unfortunatly, I havn't got a perfect solution yet. So I want to know how do you do when you handling similar scenario, how do you do when upload too many files to Azure blob storage?
Finally, I have not found what's wrong with my code.
However, I have found solution for this issue. I expire Parallel.Foreach, just use common foreach. Then I use BeginuploadFromStream method instead of UploadFromStream, it actually upload files asynchronously.
So far, it runs prefectly, more stable, without any exception happens.

Resources