It seems you are trying to attach a file from an url instead of a local path? Show the code for it
i am facing issue regarding when i attach dynamically image in email laravel api
please guide me Symfony\Component\Mime\Exception\InvalidArgumentException: Path "https://bizbuysell.jgago.com/bizapp/public/media/slider/julian.jpg" is not readable. in file /home/jgago/subdomains/bizbuysell/bizapp/vendor/symfony/mime/Part/DataPart.php on line 65
@Sinnbeck $fileToPath=[]; foreach ($businesses as $fileToPath) { foreach ($fileToPath->slider_images as $slider_image) { $fileToPath=$slider_image->full_path.$slider_image->file_name; } }
@Sinnbeck class BusinessEmailMonthly extends Mailable { use Queueable, SerializesModels; public $businesses; public $fileToPath;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct($businesses,$fileToPath)
{
$this->businesses=$businesses;
$this->fileToPath=$fileToPath;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->subject('New Business Alert')->view('emails.business_email_monthly')->attach($this->fileToPath);
}
}
@Naeem92 please format your code by adding ``` on the line before and after it
@Sinnbeck sir please have you any skype account or whatsapp please share me i stuck in this issue for one week please help me sir
@Sinnbeck sir any reply
@Naeem92 sorry but I don't work freelance. I help out on this forum for free, but that's it :) but we help many people here each and every day
@Sinnbeck sir please thats why i post this solution here please guide me
@Naeem92 are you sending multiple emails in a foreach loop? I don't understand how that foreach is related
@Sinnbeck sir i am sending multiple image to customer through this loop
@Naeem92 so $fileToPath is then an array of images, not a single image?
Can you show the output of dd($fileToPath);
it is showing like this @Sinnbeck
^ "https://bizbuysell.jgago.com/bizapp/public/media/slider/julian.jpg"
@Sinnbeck sir i dd this
@Naeem92 that's an url. Have you stored the full url to files in the database in column slider_images ?
yes sir
sir it is save in database
@Naeem92 that would be the issue then. Is that your domain or are you pointing to files on another site?
Ok quickly take down your site. Your env file is exposed. Seems you are trying to run laravel from a subdirectory. Don't do that. Try calling the website /bizapp/.env
Remember to change all of your passwords from that file
no sir when I open it in browser it is open like this https://bizbuysell.jgago.com/bizapp/public/media/slider/julian.jpg and show image but when I test it on postman it is showing error that path is not readable
sir this is not possible i can not done this because i am junior developer my senior not allowing me
@Naeem92 you have a senior that has exposed your sites passwords? Did you tell them that everyone has access to passwords to your database and such ?
@Naeem92 or do you mean you are not allowed to store just the filename in the database instead of the full url?
You need to set the document root to the /public directory.
Then you need to change all the passwords that you have in your .env file.
As it is now anyone can get access to your database and any other service that you have credentials for in your .env.
@Tray2 please give me solutions
@Naeem92 Solution for what? How to set up a laravel site on shared hosting? Or how to delete your files on there?
for above mention issue
@Naeem92 Can I recommend you fix your site first? Currently anyone has full access to your personal passwords and stripe keys. I would say that is more important that sending emails
@Sinnbeck sir how we resolve path "bizbuysell.jgago.com/bizapp/public/media/slider"path is not readable.
@Sinnbeck sir there is table media where i store image and there field is like that file_name 62d3066a9db9f_Ellipse 2.png.png file_type png folder media/slider folder_path http://bizbuysell.jgago.com/bizapp/public/media/slider/ mediable_id 11769 mediable_type App\Models\Business
@Naeem92 that folder path is an url, not a path
Try
public_path('media/slides'. $slider_image->file_name);
@Sinnbeck yes is we use public_path('media/slider'.$slider_image->file_name) instead of $fileToPath=$slider_image->folder.$slider_image->file_name;
@Naeem92 so it works now?
@Naeem92 Solve the security issue first before anything else.
The username and password to your database is viewable by all. Your stripe keys as well and your mail password.
Not a single page works on your public server either.
I suggest deleting everything on it and start over properly.
You need to set the proper document root and you need to have mod_rewrite enabled (If you are running apache). The proper document root is your apps public directory.
I have same issue..
@dekhatha then please make a thread describing your problem
@Sinnbeck but sir when i use public_path it will give wrong url "/home/jgago/subdomains/bizbuysell/bizapp/public/media/slider/julian.jpg" this is not open in browser
@Naeem92 url? You are trying to give it a path to attach the file, not add an image to the mail body
@Sinnbeck how we do that please sir
@Naeem92 I just told you. Give it the path to the file. Not the url
@Sinnbeck sir i give it to path but facing same issue path is not readable
Step 1. Remove all the files from the server.
Step 2. Setup the proper document root
Step 2.5. If you are using apache make sure mod_rewrite is enabled.
Step 3. Install the application.
Step4. Update the .env to fit you settings.
@Tray2 how we resolve above issue path is not readable sir
@Naeem92 Can you even read?
You need to fix the server first!
https://www.howtoforge.com/tutorial/install-laravel-on-ubuntu-for-apache/
@Sinnbeck sir i am facing issue regarding crone job i set cron job in cpanel but i am not receive emai please guide me where is error
@Naeem92 That sounds like a new issue. And your passwords are still exposed. I am impressed no one has abused your email yet (or maybe they have but you dont know about it)
@Sinnbeck sir no issue please guide me above this issue
@Naeem92 No. This sounds completely unrelated. If the issue regarding attaching images was solved, then mark this thread as solved and create a new thread with the new issue
Please or to participate in this conversation.