Wrox Programmer Forums
BOOK: Professional CodeIgniter ISBN: 978-0-470-28245-8
This is the forum to discuss the Wrox book Professional CodeIgniter by Thomas Myer; ISBN: 9780470282458
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional CodeIgniter ISBN: 978-0-470-28245-8 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old February 18th, 2010, 05:46 PM
Registered User
Join Date: Jan 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Thumbnail files are being renamed on upload

I am having an issue using the dashboard to create a new product. When I try to upload the image files for the product, it does upload both files (main & thumbnail) to the images folder. My scenario is I have a producted named 'toy3', I have a main image named 'toy3-main.jpg' (200 x 200) which has no problem uploading and keeping the name. I have a thumbnail image named 'toy3-thumb.jpg' (30 x 30) which upon upload changes the name to 'toy3-main.jpg.jpg' (no typo). When I reverse the order in the 'mproducts.php' model -> function addProduct (), it does the same to the main image and keeps the thumbnail name correct. It seems that the script is having an issue with the $thumb['file_name'] array and using the same name as in the previous $image['file_name'] array. Here it is as I've got it and how it is stated in the textbook (pg 172) after configuring and loading the upload library (note- The only minor change is I have taken off the leading / to the images path as I already have it configured in the base_url() of the config file): I have highlighted red what I think to be the issue.
$image = $this->upload->data();

if ($image['file_name']){
$data['image'] = "http://p2p.wrox.com/images/".$image['file_name'];

$thumb = $this->upload->data();

if ($thumb['file_name']){
$data['thumbnail'] = "http://p2p.wrox.com/images/".$thumb['file_name'];

$this->db->insert('products', $data);
Any answers to why it may be doing this? It is still working and it inserts the path to the thumbnail in the database to the newly named image file, but of course it messes with my naming convention for the other images & thumbnails already in the images folder.

Just a note: I forsee I will probably have the same issue on the updateProduct() function.

Last edited by staylor505@hotmail.com; February 18th, 2010 at 06:16 PM.. Reason: More information

Similar Threads
Thread Thread Starter Forum Replies Last Post
Upload image-create & save thumbnail-display image angshujit ASP.NET 2.0 Professional 6 July 11th, 2013 10:34 PM
creating thumbnail for pdf files via php pritz PHP How-To 0 March 10th, 2006 04:09 AM
Renamed rather than locked jminatel Classic ASP Professional 0 October 4th, 2005 01:07 PM
Renamed rather than locked jminatel Classic ASP Basics 0 October 4th, 2005 01:05 PM
upload files joeore PHP Databases 9 February 15th, 2004 05:51 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.