Hello, I have these images upload code that when I upload images on my serve it returns Image source not readable but when I try the same file at my localhost file uploaded successfully, this is the code am using to upload images
protected function uploadImagesThumb($request, $gameUploadFolder){
// loop throw the images
foreach ($request->file('g_images_thumbnails') as $imgThumb) {
// get the image name with the image ext
$imgThumbNamwWithExt = $imgThumb->getClientOriginalName();
// get the image name without the ext
$imgThumbName = pathinfo($imgThumbNamwWithExt, PATHINFO_FILENAME);
// get the image ext
$imgThumbExt = $imgThumb->getClientOriginalExtension();
//the file name that well be saved
$imgThumbNameToStore = $imgThumbName.'_'.rand().'.'.$imgThumbExt;
Storage::put('public/'.$gameUploadFolder.'/'.$this->folderName.'/thumbnails/'.$imgThumbNameToStore,fopen($imgThumb, 'r+'));
$imgThumbPath = public_path('storage/'.$gameUploadFolder.'/'.$this->folderName.'/thumbnails/'.$imgThumbNameToStore);
$img = Image::make($imgThumbPath)->resize(400,300)->save($imgThumbPath);
$this->imgThumbNameArray[] = $imgThumbNameToStore;
}
}
note that when i checked my upload folder i found that there is one image uploaded successfuly but not resized and the image that i uploaded at my localhost resized successfuly and am using the same code for the uploading process and am uploading multiable images why the upload works at local server but not on live serve. and i have another upload processes before this one and it worked successfuly with no error on both servers this is the code for the first upload maybe will help u figure out what is wrong
/**
* function to upload the main image
*/
public function uploadMainImage($request, $gameUploadFolder, $redirect){
// check if the user hit chose file and select image
if ($request->hasFile('g_image')) {
$this->validate($request, [
'g_image' => 'image|required|max:1999'
]);
$rand = mt_rand();
// get filename with ext
$imageNamwWithExt = $request->file('g_image')->getClientOriginalName();
// explode the image name and ext
$img_name_ext_array = explode('.', $imageNamwWithExt);
// get the image name
$img_name = current($img_name_ext_array);
// get the image ext
$img_ext = end($img_name_ext_array);
// get the filename and remove whitespace and other char
$fileNameToStore = preg_replace('/[^.a-zA-Z0-9]/', '-', strtolower($img_name));
// set a folder for the images to be uploaded at
$this->folderName = preg_replace('/[^a-zA-Z0-9]/', '-', trim(strtolower($request->input('g_name'))));
// the full file name with the ext
$this->fileNameToStore = $this->folderName.'_'.$rand.'.webp';
$backupFileNameToStore = $this->folderName.'_'.$rand.'.jpg';
// make a dirctory with the game name to upload the games in it
if (!Storage::disk('local')->exists($this->folderName)) {
// make a new folder to upload the images in
Storage::makeDirectory('public/'.$gameUploadFolder.'/'.$this->folderName, 0777, true, true);
}
// upload the image
$image = Image::make($request->file('g_image'));
// resize the image to suit the big screens style
$image->resize(208,130)->save(storage_path('app/public/'.$gameUploadFolder.'/'.$this->folderName.'/'. $this->fileNameToStore));
// this is the small image for the mobile devices
$sm_image = Image::make($request->file('g_image'));
// save the images
$sm_image->resize(120,80)->save(storage_path('app/public/'.$gameUploadFolder.'/'.$this->folderName.'/'.'sm_'. $this->fileNameToStore));
// this is the small image for the mobile devices
$sm_backup_image = Image::make($request->file('g_image'));
// save the images
$sm_backup_image->resize(120,80)->save(storage_path('app/public/'.$gameUploadFolder.'/'.$this->folderName.'/'.'sm_backup_'. $backupFileNameToStore));
// this is the small image for the mobile devices
$backup_image = Image::make($request->file('g_image'));
// save the images
$backup_image->resize(208,130)->save(storage_path('app/public/'.$gameUploadFolder.'/'.$this->folderName.'/'.'backup_'. $backupFileNameToStore));
}else{
return redirect('/admin/'.$redirect.'/create')->with('error', 'Sorry but the image is required.');
}
}