Welcome Guest, Not a member yet? Register   Sign In
Route with optional param is not working
#4

(06-07-2016, 01:33 PM)cartalot Wrote: this doesn't make any sense. are you really saying this is your url?
http://localhost/PROJECT/admin/product/image
how could that be a delete request when you are not specifying an id (number) to delete?

The delete request also takes a URL to delete temp images that don't have ID yet.
BTW the solution was
PHP Code:
$route["admin/product/image/?(:num)?"]["delete"] = "product/deleteImage/$1"

to make parameter optional.
even though the functions is defined as
PHP Code:
public function deleteImage($imageId=0) {
        
$url $this->sanitize->removeTags()->sanitize($this->commonlib->request("url"));
        if(!empty(
$url)){
            @
unlink($this->config->item("temp_upload_dir").$url);
            
$this->commonlib->sendResponse(200"Product Image Removed");
        }
        else{
            
        }
    } 
Harpreet Bhatia
Web Developer / Analyst
Technical Reviewer - "Codeigniter 2 Cookbook"

Reply


Messages In This Thread
RE: Route with optional param is not working - by harpreet - 06-07-2016, 10:26 PM



Theme © iAndrew 2016 - Forum software by © MyBB