Welcome Guest, Not a member yet? Register   Sign In
uploading and using images
#3

[eluser]M4rc0[/eluser]
This is exactly what i want, maybe we can help each other here Dan.

I've read the whole documentation and it's not clear how to save on database and display it later.

Before saving to database or uploading the picture (photo or avatar, w/e), the filename should always be renamed, that should be standard on the library imo. So my first question was how to rename the picture before uploading, upload and then save the path/filename to database so i could display later.

Looks like the first proccess is here, Thanks for sharing that code textnotspeech!
I want to rename the whole filename, not just pend or append (append only for thumb).
So i've done some change in your code, correct me if i'm wrong:

Code:
function rename_file($filename, $new_name)
        {
            //$imagename = substr($filename, 0, -4); // extract the image name
            $extension = substr($filename, -4); // extract the extension
            // Not all image extensions are created equal, we're expecting a 3 letter extension so if we get a .jpeg extension, let's convert it
            if($extension == "jpeg")
            {
                //$imagename = substr($imagename, 0, -1);
                $extension = '.jpg';
            }
            $extension = strtolower($extension); // I like uniform lowercase file extensions
            $new_filename = $new_name.$extension; // put the filename string together
            return $new_filename;
        }

So either i want to generate a random hash or a custom name (such as id+date or something) i call that function and i have what i want.

Now the question is, where do i put my new name on do_upload ? There isn't any parameter for filename. How did you do it textnotspeech ?

Could it be like this maybe?
Code:
$myname = rename_file([i]what goes here?[/i],$this->post('name'));
$config['new_image'] = '/path/'.$myname;

EDIT: Right, and what about the thumbnail new name? It should be $new_name.'_thumb'.$extension; If i add that on the function above (with a case for thumb), where will i add this new_filename for the thumb?

Thanks Big Grin


Messages In This Thread
uploading and using images - by El Forum - 09-14-2008, 08:24 AM
uploading and using images - by El Forum - 09-14-2008, 07:36 PM
uploading and using images - by El Forum - 09-16-2008, 01:51 PM
uploading and using images - by El Forum - 09-16-2008, 05:38 PM
uploading and using images - by El Forum - 09-17-2008, 03:00 AM
uploading and using images - by El Forum - 09-17-2008, 09:24 AM
uploading and using images - by El Forum - 09-17-2008, 09:39 AM
uploading and using images - by El Forum - 09-17-2008, 10:11 AM
uploading and using images - by El Forum - 09-17-2008, 10:55 AM
uploading and using images - by El Forum - 09-17-2008, 11:05 AM
uploading and using images - by El Forum - 09-17-2008, 11:19 AM
uploading and using images - by El Forum - 09-17-2008, 11:42 AM
uploading and using images - by El Forum - 09-17-2008, 12:16 PM
uploading and using images - by El Forum - 09-18-2008, 11:28 AM
uploading and using images - by El Forum - 09-19-2008, 06:20 AM
uploading and using images - by El Forum - 09-19-2008, 06:36 AM
uploading and using images - by El Forum - 09-19-2008, 06:38 AM
uploading and using images - by El Forum - 09-19-2008, 07:00 AM
uploading and using images - by El Forum - 09-19-2008, 07:08 AM
uploading and using images - by El Forum - 09-19-2008, 07:09 AM
uploading and using images - by El Forum - 09-19-2008, 07:11 AM
uploading and using images - by El Forum - 09-19-2008, 07:12 AM
uploading and using images - by El Forum - 09-19-2008, 07:19 AM
uploading and using images - by El Forum - 09-19-2008, 07:21 AM
uploading and using images - by El Forum - 09-19-2008, 09:13 AM
uploading and using images - by El Forum - 09-20-2008, 12:54 PM
uploading and using images - by El Forum - 09-20-2008, 02:46 PM
uploading and using images - by El Forum - 09-20-2008, 03:11 PM
uploading and using images - by El Forum - 09-20-2008, 03:28 PM
uploading and using images - by El Forum - 09-20-2008, 03:59 PM
uploading and using images - by El Forum - 09-20-2008, 04:10 PM
uploading and using images - by El Forum - 09-20-2008, 04:32 PM
uploading and using images - by El Forum - 09-20-2008, 05:41 PM
uploading and using images - by El Forum - 09-22-2008, 01:35 PM
uploading and using images - by El Forum - 09-22-2008, 01:59 PM
uploading and using images - by El Forum - 09-22-2008, 02:01 PM
uploading and using images - by El Forum - 09-23-2008, 02:57 AM
uploading and using images - by El Forum - 09-23-2008, 03:02 AM
uploading and using images - by El Forum - 09-23-2008, 03:19 AM
uploading and using images - by El Forum - 09-23-2008, 03:24 AM
uploading and using images - by El Forum - 09-23-2008, 03:38 AM
uploading and using images - by El Forum - 09-23-2008, 03:47 AM
uploading and using images - by El Forum - 09-23-2008, 04:16 AM
uploading and using images - by El Forum - 09-23-2008, 04:21 AM
uploading and using images - by El Forum - 09-23-2008, 10:11 AM



Theme © iAndrew 2016 - Forum software by © MyBB