matinee Posted February 7, 2015 Share Posted February 7, 2015 images of books fails to display properly in homepage, broken image is displayed instead. please solve the problem Home » Books Books Displaying 1-6 of 6 results. Title: The Yii BookPrice: $20.00Author: Larry UllmanDate Published: Dec. 31, 2024 Title: Effortless E-commerce with PHP and MySQL (2nd Edition)Price: $44.99Author: Larry UllmanDate Published: Nov. 30, 2013 Title: PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)Price: $0.40Author: Larry UllmanDate Published: Aug. 16, 2012 Link to comment Share on other sites More sharing options...
Larry Posted February 9, 2015 Share Posted February 9, 2015 What is the URL you're using for the site? What is the src value of those image tags? Link to comment Share on other sites More sharing options...
matinee Posted February 20, 2015 Author Share Posted February 20, 2015 I was actually trying the chapter 23 example, e-commerce site the code is <?php echo '<img src="/images/'.$model->id.'.jpg">'; ?> It just display a broken picture. The image fails to display properly. The images are in the images folder Pliz help Link to comment Share on other sites More sharing options...
Larry Posted February 20, 2015 Share Posted February 20, 2015 Okay. What is the URL you're using for the site? And where is the images folder on the file system? Link to comment Share on other sites More sharing options...
matinee Posted February 21, 2015 Author Share Posted February 21, 2015 I am using localhost. C:\xampp\htdocs\yiiecom The images folder is at the application folder. C:\xampp\htdocs\yiiecom\images Link to comment Share on other sites More sharing options...
Larry Posted February 21, 2015 Share Posted February 21, 2015 Okay, good. I assume, then, that the URL you're using is http://localhost/yiiecom. If so, then the values for the img src attributes have to be /yiiecom/images. The default value of /images means the browser will look for the images in the "images" folder in the web root directory, C:\xampp\htdocs\images, in your case. Make that change and you should be good. Link to comment Share on other sites More sharing options...
matinee Posted February 23, 2015 Author Share Posted February 23, 2015 thanks a lot Larry, now I get the images of the books. The problem is solved But, what should I do to keep the images folder inside the apllication folder. How I should modify the code in the "view.php" and "_view.php" to display the image when the images folder is inside the application folder. Link to comment Share on other sites More sharing options...
matinee Posted February 23, 2015 Author Share Posted February 23, 2015 pliz help. Link to comment Share on other sites More sharing options...
Larry Posted February 23, 2015 Share Posted February 23, 2015 Hey! So, just to be clear, you never need to post "please help". I will help, or someone else will, but I almost certainly won't get back to you within an hour of when you just posted. Please try to be patient. I'm not sure I followed your most recent post. Your view files should only need to have the same update as you did for the index file. Just use the proper reference to the images as they're stored on the file system. Also, the images are in the web directory, not within the application folder. Link to comment Share on other sites More sharing options...
matinee Posted February 24, 2015 Author Share Posted February 24, 2015 Finally got it. changing the img src to "/yiiecom/images/ does the job <?php echo CHtml::link('<img src="/yiiecom/images/' . $data->id . '.jpg">', array('view', 'id'=>$data->id)); ?> Why I didn't get it before inspite of it having been explained by you <"Okay, good. I assume, then, that the URL you're using is http://localhost/yiiecom. If so, then the values for the img src attributes have to be /yiiecom/images. The default value of /images means the browser will look for the images in the "images" folder in the web root directory, C:\xampp\htdocs\images, in your case. Make that change and you should be good."> Thanks a lot Larry for your valuable help. Link to comment Share on other sites More sharing options...
Larry Posted February 25, 2015 Share Posted February 25, 2015 Awesome, excellent. Glad you've both solved the problem and got a better grasp on why that's the solution. Let us know when you have any other questions! Link to comment Share on other sites More sharing options...
Recommended Posts