Welcome Guest, Not a member yet? Register   Sign In
  CI_Image_lib::image_save_gd() -- always returns TRUE regardless
Posted by: El Forum - 08-10-2008, 07:28 PM - No Replies

[eluser]coolfactor[/eluser]
This function always returns TRUE whether or not it was able to save the image. Since the internal calls to imagegif(), imagejpg() and imagepng() are silenced in this function, no error is displayed. Then the function defaults to returning TRUE at the end of its call, so the function that called it has no idea that it wasn't able to do its job.

How to reproduce:
Attempt to resize an image to a non-existent folder. The resize() operation will pass with flying colors, but no resized image will be found.

Possible solutions:

1. Validate that the destination path is writeable before calling this function.
or
2. Return FALSE from this function and handle that in the calling code.

Note: this is not a function called directly from outside of the Image_lib. It's called internally, so the only way for a user of the library to fix it would be subclass the Image_lib class and put the fix in the subclass. The permanent fix needs to be part of a CodeIgniter update.


  Image Lib Config File
Posted by: El Forum - 08-10-2008, 05:59 PM - Replies (1)

[eluser]megabyte[/eluser]
The user guide states the following:

If you prefer not to set preferences using the above method, you can instead put them into a config file. Simply create a new file called image_lib.php, add the $config array in that file. Then save the file in: config/image_lib.php and it will be used automatically. You will NOT need to use the $this->image_lib->initialize function if you save your preferences in a config file.


Which is great because you can seprate all your config values. Problem is what do you do if you want to store the config values for more than one image manipulation script?

Can you use a multi dimensional array for the $config

I tried to use my own config file and it didnt work, I had a controller called image_gallery.php and created a cofig file under the config folder called image_gallery.php I then loaded it, and the values were available using $this->config->item() but they were not automatically available like they are when you set them in a config file called image_lib.php.

Am I correct? has anyone else noticed this? Or did I make a mistake somewhere?


  Protype ajax validation problem
Posted by: El Forum - 08-10-2008, 03:50 PM - Replies (14)

[eluser]Michael;[/eluser]
I've been working on this for a day and a half now and I'm about to pull my hair out. I know it has to be something simple, or I would have been able to work it out by now.

Basically, I'm using ajax to validate form fields inline and am hiding the submit button until all fields that are required are filled in (and validated when required), the problem is that $this->input->post('field') will absolutely *NOT* validate if empty. In fact, rather the opposite, like so:

Code:
function required() {
    if(!preg_match('/^.$/', $this->obj->input->post('value'))) {
      print "This field is required.";
    }
  }

The above will return a "valid" response if you tab through the field and leave nothing in it, if you put '123' into the field it returns invalid. If you remove the '!' ( as in preg_match ) it weill still return a valid response if the field is empty.

I have tried everything from "empty()" and "strlen()" to the above regex and "== ''". NOTHING is working.

Now, here's the really odd thing... if I use the ajax outside of CI it works perfectly.

Code:
// validation javascript
function ValidateField(input, container, validation) {
  new Ajax.Request('validator.php', {
    parameters: {validation: validation, value: $F(input)},
      onComplete: function(AjaxResult){
        if(AjaxResult.responseText){
          $(input).setStyle({border:'1px #C00 solid'});
          $(container).update(' '+AjaxResult.responseText);
        }else{
          $(input).setStyle({border:'1px solid'});
          $(container).update('Valid');
        }
      }
    });
  }

and the html markup:

Code:
First Name: <input type="text" name="first_name" maxlength="25"
value="<?=$this->validation->first_name;?>" size="25"
onblur="ValidateField(this, 'first_name', 'required')"/>
<span id="first_name" style="color:#C00">* Required</span>

Everything else validates just fine; from email addresses and phone numbers to db checks for present data ... it's as if $this->input->post() has a "positive value" no matter what is ( or is not ) actually *IN* the field.

I am completely stuck here and this is kind of a deal breaker for my project ... and if I have to start over outside of CI I'm going to tear my hair out.


  Need Help on Ajax
Posted by: El Forum - 08-10-2008, 11:39 AM - Replies (11)

[eluser]Nutan Lade[/eluser]
I am trying to something like Google Suggest.
And the code I wrote in my application is below

gadgets_view.php
------------------------------------------


function changeLang(){
//alert("hi");
var url = "&lt;?=base_url()?&gt;index.php/gadgets/lang/"+document.getElementById("lang").value;
alert(url);
[removed]="&lt;?=base_url()?&gt;index.php/gadgets/lang/"+document.getElementById("lang").value;
}


&lt;!--
var req;
function getServerName()
{
var str = [removed].protocol + '//' + [removed].hostname;
return str;
}
function loadXMLDoc(url) {

// Internet Explorer
try { req = new ActiveXObject("Msxml2.XMLHTTP"); }
catch(e) {
try { req = new ActiveXObject("Microsoft.XMLHTTP"); }
catch(oc) { req = null; }
}
// Mozailla/Safari
if (!req && typeof XMLHttpRequest != "undefined") { req = new XMLHttpRequest(); }


// Call the processChange() function when the page has loaded
alert(url);if(req !=null){
req.open("GET", url, true);
req.onreadystatechange = processChange;
req.send(null);
}
}

function processChange() {
// The page has loaded and the HTTP status code is 200 OK
if (req.readyState == 4 && req.status == 200) {

// Write the contents of this URL to the searchResult layer
getObject("searchResult")[removed] = req.responseText;

}
}

function getObject(name) {
var ns4 = (document.layers) ? true : false;
var w3c = (document.getElementById) ? true : false;
var ie4 = (document.all) ? true : false;

if (ns4) return eval('document.' + name);
if (w3c) return document.getElementById(name);
if (ie4) return eval('document.all.' + name);
return false;
}


window.onload = function() {
getObject("movieSearch").focus();
}

// --&gt;
[removed]


&lt;body&gt;
<table>
<tr>
<td>&lt;input type="text" id="movieSearch" name="movieSearch" &gt;&lt;/td>
</tr>
<tr>
<td><div align="center" id="searchResult" name="searchResult" style="font-family:Arial; font-size:12px; width:150px; border:#000000 solid 1px; "></div></td>
</tr>
</table>

&lt;/body&gt;


gadgets.php
----------------------------------------------------------------------------------
function searchMovie(){

$results = "";
$pat = $this->uri->segment(3);

$query = $this->db->query("SELECT * FROM movies_list WHERE movie_name LIKE '$pat%' LIMIT 10");

foreach ($query->result() as $row)
{
$results = $results."<b>$row->movie_name</b><br />";
}
return $results;

}


But the results is not written back.But the localhost page is written as the result.Please help me how to solve this one.Thanq in advance.


  Upload errors?
Posted by: El Forum - 08-10-2008, 10:21 AM - No Replies

[eluser]ywftdg[/eluser]
What is the best way to trigger upload error messages? Like stop the upload process, if file is too large or wrong type? I was trying some things like if (!$this->upload->do_upload()), but that was causing all sorts of problems with my overall process of the controller, as well the upload is not required. Any ideas, or did I miss something in previous posts?


  Simple upload problem
Posted by: El Forum - 08-10-2008, 08:19 AM - Replies (4)

[eluser]markanderson993[/eluser]
I am having considerable trouble getting my file field to be picked up by my controller. It is like the name field is not sending its value over to the controller. Every time I submit the form It gives me the same, "please fill in your file selection field". Ahh! Why does this happen?

If anyone has an explanation for this I would be very thankful.

Here is the controller:

Code:
if (isset($_POST['create_image_group']))
        {
            $image_group_name = $this->input->post('image_group_name');
            
            if ($image_group_name != '')
            {
                $this->upload_model->create_image_group($id,'custom',$image_group_name);
                $data['success'] = 'The image album entitled: <b>'.$image_group_name.'</b> has been successfully created';
            } else {
                $data['error'] = 'Please enter a title for your image group';
            }
        }

And the view

Code:
&lt;?php echo form_open_multipart('images/managealbums/'.$this->uri->segment(3));?&gt;

<div style="margin-top:5px;"><b>Select an album:</b>
<select style="font-size:11px;" name="image_group_id" >
&lt;?php if (isset($image_groups)): ?&gt;
    &lt;?php foreach($image_groups->result() as $row): ?&gt;
    <option value="&lt;?php echo $row->image_group_id?&gt;">&lt;?php echo $row->image_group_name?&gt;</option>
    &lt;?php endforeach; ?&gt;
&lt;?php endif; ?&gt;
</select></div>

<div style="margin-top:5px;"><b>Select an image</b></div>

&lt;input type="file" name="userfile" size="20" /&gt;

<div style="margin-top:5px;"><b>Title <span style="color:#666;font-size:9px;position:relative;top:-1px;">(optional)</span></b><br />&lt;input type="text" name="image_title"&gt;&lt;/div>

<div style="margin-top:5px;">
<b>Description <span style="color:#666;font-size:9px;position:relative;top:-1px;">(optional)</span></b>&lt;textarea name="image_desc" style="padding:2px;font-size:11px;font-family:Arial, Helvetica, sans-serif;width:100%;height:100px;"&gt;&lt;/textarea>
</div>

<div style="margin-top:5px;">&lt;input type="submit" name="upload_album_picture" value="upload" /&gt;&lt;/div>

&lt;/form&gt;


  Checking to see if there is file upload? [solved]
Posted by: El Forum - 08-10-2008, 05:03 AM - Replies (5)

[eluser]ywftdg[/eluser]
I currently have a system where a user can update their name and avatar. The upload works great with images, etc, but if I do not upload an image, I get an error saying no file was chosen. Sometimes the user might just update their web address. What can I use to check "if there is a file being uploaded, then run my upload process" ?

Any help would be greatly appreciated.


  Access to libray or model from another model
Posted by: El Forum - 08-10-2008, 04:54 AM - Replies (2)

[eluser]Unknown[/eluser]
Hello people. I am sorry for my bad english. But I have a question. Can I load the library or model from another model?

This error
"A PHP Error was encountered
Severity: Notice
Message: Undefined property: Files_model::$catalog
Filename: models/files_model.php
Line Number: 9
Fatal error: Call to a member function set_cat_type() on a non-object in D:\server\www\lehe\core\application\models\files_model.php on line 9"
appears when I tryed to execute this code:

Code:
class Files_model extends Model
{
    function __construct()
    {
        parent::Model();
        $this->load->library('catalog');
        $this->catalog->set_cat_type('files');
    }

        function get_file_list()    
        {
                return $this->catalog->get_catalog_list();
        }

          . . . . . .
}


  Conceptual question: tags in blog posts
Posted by: El Forum - 08-10-2008, 03:25 AM - Replies (13)

[eluser]Référencement Google[/eluser]
Hi,

Before starting something, I am trying to plan how I will do that.

I need to do a blog where different registred users can add word tags to their posts, so when a visitor click on a tag he can retrieve all posts concerning a specific tag. Unfortunately I can't use a solution like wordpress or EE, I must to build it from scratch.

So my question is:
How would you plan the Database schema to manage this tags?


  The filetype you are attempting to upload is not allowed
Posted by: El Forum - 08-10-2008, 02:53 AM - No Replies

[eluser]PHP Programmer[/eluser]
Hi

I am getting an error while running file upload function. I am uploading the file format same as defined under 'allowed_types'/'mimetypes' ie gif,png,jpg.

Also, if I run it independently then it works fine but when I embed it in my code then the following error occurs.

The error says:

Array ( [error] =>

The filetype you are attempting to upload is not allowed
)

My Code is: (Under 'controller' directory)

$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';

$this->load->library('upload', $config);

if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());

print_r($error);
}
else
{
$data = array('upload_data' => $this->upload->data());

echo "success";
}


Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Latest Threads
Version number stays un-u...
by trunky
3 hours ago
codeigniter4/queue Not lo...
by mywebmanavgat
7 hours ago
Array to HTML "Table"
by HarmW94
8 hours ago
shortcodes for ci4
by xsPurX
9 hours ago
TypeError when trying to ...
by b126
Today, 12:04 AM
Webhooks and WebSockets
by InsiteFX
Yesterday, 10:39 AM
Retaining search variable...
by pchriley
Yesterday, 05:46 AM
Reading a session variabl...
by xanabobana
Yesterday, 05:05 AM
Update to v4.5.1, same us...
by kenjis
04-17-2024, 07:47 PM
Codeigniter 4 extend core...
by Semsion
04-17-2024, 05:08 AM

Forum Statistics
» Members: 84,590
» Latest member: olnagazurorg
» Forum threads: 77,560
» Forum posts: 375,900

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB