Welcome Guest, Not a member yet? Register   Sign In
Image Resize - How to find the stored file name?
#1

[eluser]Namsu[/eluser]
The upload function lets you get the name of the image when stored, since its important for me to add that name to the database (as the upload class checks for duplicate names in directory). Is there any way that the Image_Lib library will give me the name after its stored, since I want to make sure I have the right file and not some accidental left over?
#2

[eluser]mi6crazyheart[/eluser]
If u want to store the image name in u'r DB then better , select a name from u'r side before uploading the image file to it's destination folder. Then, at the time of upload u can use that name to rename u'r image file and upload it. After this, u can also send that file name to the DB...
#3

[eluser]RedIgniter[/eluser]
I haven't used the image helper if there is one with codeigniter, but wih PHP I would use the function to split the name and whats before .jpg (or whatever the extension is) to store in the database, also insert in the db the path the picture is gonna be in, and make a folder with that path name and upload the picture in it, then its easy to get the data from database to show images. Hope it helps.
#4

[eluser]Unknown[/eluser]
It's easy
just add 'file' library to your controller and use 'read_file' function to read the file name you uploaded

controller
Code:
$this->load->helper('file');

if(isset($_FILES['userfile'])){
$file     = read_file($_FILES['userfile']['tmp_name']);
echo $name     = basename($_FILES['userfile']['name']);

view
Code:
<input type="file" name="userfile" size="40" />




Theme © iAndrew 2016 - Forum software by © MyBB