Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting The "/tmp/****" file does not exist or is not readable. #1613

Closed
hazem-taha opened this issue Oct 30, 2019 · 13 comments
Closed

Getting The "/tmp/****" file does not exist or is not readable. #1613

hazem-taha opened this issue Oct 30, 2019 · 13 comments

Comments

@hazem-taha
Copy link

Hello,

I'm getting the below error even if I'm uploading very small images.

image

any solution ??

Thanks

@trantrongbinh
Copy link

trantrongbinh commented Oct 31, 2019

GD Library extension not available with your PHP installation.
try:

PHP5: sudo apt-get install php5-gd
PHP7.0: sudo apt-get install php7.0-gd
PHP7.1: sudo apt-get install php7.1-gd
PHP7.2: sudo apt-get install php7.2-gd
PHP7.3: sudo apt-get install php7.3-gd

you use docker then add into dockerfile:

RUN docker-php-ext-configure gd --with-gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-png-dir=/usr/include/
RUN docker-php-ext-install gd

or if you use imagick then checked imagick in phpinfo() is enabled? if not enabled then put extension=imagick into the php.init file

@freekmurze
Copy link
Member

@hazem-taha it's probably related to some permission setting in your environment. If there is something that can be done in medialibrary to fix this, send a PR.

@tiagosimoesdev
Copy link

I'm getting the same issue . Already tried in Windows, macOS and linux ..

@harryWonder
Copy link

I also got the same issue... The upload logic works fine for some controllers but doesn't for others.

@m7md3omr
Copy link

m7md3omr commented Feb 16, 2020

Hello
this issue happen to me also , but i figure out that, In my case i was adding same information twice in two different languages in two different database id for example english and arabic and each will have it is own record, and each record should be related to media table .
so the file was already moved from tmp/upload folder when the second record id try to access the file.
i manage this by adding preservingOriginal() to the first record id accessing the file
$user_en->addMedia($strorage_path)->preservingOriginal() ->toMediaCollection('posts');
then i removed it from the second record id
$user_lang->addMedia($strorage_path)->toMediaCollection('posts');

what i do was try to preserve the file in temp/uploads while the adding sequence still in progress. then remove it in the last record insertion.

that is because FileAdder class still accessing the file information when you move files from temp to media collection

@jinseokoh
Copy link

I'm using Laravel 7.11 w/ PHP 7.4.5. The following code gives me an error like The file "/tmp/phpcCjOmG" does not exist when using FormRequest but, works fine with Illuminate\Http\Request.

$model->addMedia($request->file('image'))
            ->toMediaCollection();

@MuhammadSulman
Copy link

@jinseokoh Man, you are right, it works, but I don't know how, if you have any reason about it then please share it.

@jojomak13
Copy link

@jinseokoh thanks for that it works fine after using the native request not the formRequest

@eskiesirius
Copy link

eskiesirius commented Apr 6, 2022

I am getting this issue.. changing addMediaFromRequest to addMedia didn't work.. im using windows..

$customer->addMediaFromRequest('customer_picture')
	            ->usingName($name)
	            ->usingFileName("$name.$ext")
	            ->toMediaCollection('customer_picture');

currently i have two project that are using this package, my first project don't have any issues..

EDIT:
I found this article https://laracasts.com/discuss/channels/requests/spatie-media-library-upload-always-leads-to-request-does-not-have-a-file-in-a-key-named, it seems that it cant access temp when in php artisan serve mode

EDIT:
I added preservingOriginal() and it worked

@akhzarjaved
Copy link

I'm using Laravel 7.11 w/ PHP 7.4.5. The following code gives me an error like The file "/tmp/phpcCjOmG" does not exist when using FormRequest but, works fine with Illuminate\Http\Request.

$model->addMedia($request->file('image'))
            ->toMediaCollection();

Facing same issue. Using version 10.3.4
well i have used addMediaFromRequest('file-name') and it seems to be working fine.

@igitonga
Copy link

preservingOriginal()

I did this $user->addMediaFromRequest("avatar")->preservingOriginal()->toMediaCollection('avatar'); yes it solved the issue but i would find the same media being uploaded twice.

@Ochieng424
Copy link

preservingOriginal()

I did this $user->addMediaFromRequest("avatar")->preservingOriginal()->toMediaCollection('avatar'); yes it solved the issue but i would find the same media being uploaded twice.

Did you find a fix for the duplicate uploads? I am facing the same issue as well

@igitonga
Copy link

preservingOriginal()

I did this $user->addMediaFromRequest("avatar")->preservingOriginal()->toMediaCollection('avatar'); yes it solved the issue but i would find the same media being uploaded twice.

Did you find a fix for the duplicate uploads? I am facing the same issue as well

Yeah i omitted preservingOriginal()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests