Dynamic image slider using php and mysqli [closed] - php

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I do want to display image slider which is being uploaded by the admin to the slider using php and mysqli. If the admin wants to change the images he would be able to do it by uploading or deleting the images.

Add the image and display
Store the image in a folder by using move_uploaded_file()
Store the image name and path in database
Display it in html by using select query <img src="<?php echo $img; ?>" />
While modify the image
Select the image from database and remove it unlink($file)
Upload new image in directory and update the path in database.
Delete the image
Select the image from database and remove it unlink($file)
Delete the row from database.

Related

How to get image data from database mysql in react native [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I have a problem, I am using backend with Codeigniter and upload the image to MySQL with varchar type.
This is the name of the image after I input:
and now I want to get that image to react native with fetch API, but how to get image from database to react native, because in MySQL just the name of the picture is saved? please help me
You have to save the file on the server's disk and filename name in your database. You'll have to know the location of your file so when you want to fetch it you'll have to build a full url to the file like http://example-domain.com/uploads/filename.jpg or you can save the full path in the database instead of just a filename. If you don't have a server to store the image you may consider saving the image blob into the database which I don't recommend.

Route to image in Laravel [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I am using the Laravel framework and trying to display an image in a view. Here is the code in the show template that displays the image.
<img src="storage/cover_images/{{$post->cover_image}}">
In this file, I define the storage directory for the image
But the image won't show in the browser, it just pointing to this path
http://localhost/lsapp/public/posts/storage/cover_images/noimage.jpg while my images are in the lsapp/storage/app/public/cover_images folder.
Based on your question..as you want to display image in view.
run Command: php artisan storage:link
after that now you can display your image in view using Storage:url
<img src="{{ Storage:url($post->cover_image) }}">
Make sure to post code next time instead of screenshot.

PHP while loop to display images from MySQL [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I have a MySQL table storing images and a code which displays an image on the site.
$sql = "SELECT * FROM upload";
$sth = $db->query($sql);
$result=mysqli_fetch_array($sth);
echo '<img src="data:image/jpeg;base64,'.base64_encode( $result['content'] ).'"/>';
I want to display all images with a while loop.
Please don't tell me "Don't put images in your database" or something like that.
Your approach is wrong from the beginning! Saving as a blob type is not a good approach anymore as it just puts additional load on the database. Instead, what you should do is upload file to a specific folder on your hosting using:
move_uploaded_file($filetmp,$filepath);
Guide for move_uploaded_file
Then save the uploaded file path in the database.
After that, wherever you need to use the images get the path from db and in src of img echo that path.

How chnage image size before uploaded on server [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I want to change image size before uploaded on server/mysql database, As its for member, so member can uploaded big images in size and i want to prevent and assign a new image size of their images.
I need it in PHP.
Thanks
Resizing an image in php without uploading first is not possible as php only runs on the server side. It can be done with js though, there are a lot of libraries that can help you out, like Jimp, Jcrop and Processing.js.
If you really want it in php than the image has to be uploaded first and than you will be able the resize the image with imagecopyresized function for example.
The php manual has an example here

Storing a file into a database & uploading it in a webpage [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Background
I'm creating a website where the user can store an article as a file in the database and than upload the file's content into a page in the website using a form. The file may only contain text or image or both.
Question
Can anyone walk me through this?
I would suggest you to create a database table having fields having the userId, and path of the file.
The file uploaded should be saved in the Web Server, and its path need to be saved in the database.
The vice-versa should be done while retrieving the file content.

Categories