Note that there are some explanatory texts on larger screens.

plurals
  1. POCodeigniter jQuery File Upload Unexpected Token
    primarykey
    data
    text
    <p>I am trying to implement <a href="http://vortexdev.netii.net/article_20/Integrate_jQuery_File_Upload_with_CodeIgniter" rel="nofollow">this</a> tutorial, I believe I have done the exactly what it said in the tutorial. But I am getting this error after the download process seems to be finished.</p> <blockquote> <p><code>Error SyntaxError: Unexpected token &lt;</code></p> </blockquote> <p>Here you can see my controller:</p> <pre><code>&lt;?php class Upload extends CI_Controller{ function __construct() { parent::__construct(); } public function index() { $this-&gt;load-&gt;view("upload"); } public function upload() { error_reporting(E_ALL | E_STRICT); $this-&gt;load-&gt;helper("upload.class"); $upload_handler = new UploadHandler(); header('Pragma: no-cache'); header('Cache-Control: no-store, no-cache, must-revalidate'); header('Content-Disposition: inline; filename="files.json"'); header('X-Content-Type-Options: nosniff'); header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Methods: OPTIONS, HEAD, GET, POST, PUT, DELETE'); header('Access-Control-Allow-Headers: X-File-Name, X-File-Type, X-File-Size'); switch ($_SERVER['REQUEST_METHOD']) { case 'OPTIONS': break; case 'HEAD': case 'GET': $upload_handler-&gt;get(); break; case 'POST': if (isset($_REQUEST['_method']) &amp;&amp; $_REQUEST['_method'] === 'DELETE') { $upload_handler-&gt;delete(); } else { $upload_handler-&gt;post(); } break; case 'DELETE': $upload_handler-&gt;delete(); break; default: header('HTTP/1.1 405 Method Not Allowed'); } } </code></pre> <p>}</p> <p>There is a class that makes all the upload stuff, which is put into helpers folder. I am suspecting that putting not functions but a class into helper folder can cause the problem? However, the error, I think, not related to this. Maybe the problem with the jQuery, but again not sure.</p> <p>Here is the some portion of my view for you to check out:</p> <pre><code>&lt;form id="fileupload" action="&lt;?=base_url()?&gt;upload/upload" method="POST" enctype="multipart/form-data"&gt; &lt;!-- The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload --&gt; &lt;div class="row fileupload-buttonbar"&gt; &lt;div class="span7"&gt; &lt;!-- The fileinput-button span is used to style the file input field as button --&gt; &lt;span class="btn btn-success fileinput-button"&gt; &lt;i class="icon-plus icon-white"&gt;&lt;/i&gt; &lt;span&gt;Add files...&lt;/span&gt; &lt;input type="file" name="files[]" multiple&gt; &lt;/span&gt; &lt;button type="submit" class="btn btn-primary start"&gt; &lt;i class="icon-upload icon-white"&gt;&lt;/i&gt; &lt;span&gt;Start upload&lt;/span&gt; &lt;/button&gt; &lt;button type="reset" class="btn btn-warning cancel"&gt; &lt;i class="icon-ban-circle icon-white"&gt;&lt;/i&gt; &lt;span&gt;Cancel upload&lt;/span&gt; &lt;/button&gt; &lt;button type="button" class="btn btn-danger delete"&gt; &lt;i class="icon-trash icon-white"&gt;&lt;/i&gt; &lt;span&gt;Delete&lt;/span&gt; &lt;/button&gt; &lt;input type="checkbox" class="toggle"&gt; &lt;/div&gt; &lt;!-- The global progress information --&gt; &lt;div class="span5 fileupload-progress fade"&gt; &lt;!-- The global progress bar --&gt; &lt;div class="progress progress-success progress-striped active"&gt; &lt;div class="bar" style="width:0%;"&gt;&lt;/div&gt; &lt;/div&gt; &lt;!-- The extended global progress information --&gt; &lt;div class="progress-extended"&gt;&amp;nbsp;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;!-- The loading indicator is shown during file processing --&gt; &lt;div class="fileupload-loading"&gt;&lt;/div&gt; &lt;br&gt; &lt;!-- The table listing the files available for upload/download --&gt; &lt;table class="table table-striped"&gt;&lt;tbody class="files" data-toggle="modal-gallery" data-target="#modal-gallery"&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;/form&gt; &lt;script id="template-upload" type="text/x-tmpl"&gt; {% for (var i=0, file; file=o.files[i]; i++) { %} &lt;tr class="template-upload fade"&gt; &lt;td class="preview"&gt;&lt;span class="fade"&gt;&lt;/span&gt;&lt;/td&gt; &lt;td class="name"&gt;&lt;span&gt;{%=file.name%}&lt;/span&gt;&lt;/td&gt; &lt;td class="size"&gt;&lt;span&gt;{%=o.formatFileSize(file.size)%}&lt;/span&gt;&lt;/td&gt; {% if (file.error) { %} &lt;td class="error" colspan="2"&gt;&lt;span class="label label-important"&gt;{%=locale.fileupload.error%}&lt;/span&gt; {%=locale.fileupload.errors[file.error] || file.error%}&lt;/td&gt; {% } else if (o.files.valid &amp;&amp; !i) { %} &lt;td&gt; &lt;div class="progress progress-success progress-striped active"&gt;&lt;div class="bar" style="width:0%;"&gt;&lt;/div&gt;&lt;/div&gt; &lt;/td&gt; &lt;td class="start"&gt;{% if (!o.options.autoUpload) { %} &lt;button class="btn btn-primary"&gt; &lt;i class="icon-upload icon-white"&gt;&lt;/i&gt; &lt;span&gt;{%=locale.fileupload.start%}&lt;/span&gt; &lt;/button&gt; {% } %}&lt;/td&gt; {% } else { %} &lt;td colspan="2"&gt;&lt;/td&gt; {% } %} &lt;td class="cancel"&gt;{% if (!i) { %} &lt;button class="btn btn-warning"&gt; &lt;i class="icon-ban-circle icon-white"&gt;&lt;/i&gt; &lt;span&gt;{%=locale.fileupload.cancel%}&lt;/span&gt; &lt;/button&gt; {% } %}&lt;/td&gt; &lt;/tr&gt; {% } %} &lt;/script&gt; &lt;!-- The template to display files available for download --&gt; &lt;script id="template-download" type="text/x-tmpl"&gt; {% for (var i=0, file; file=o.files[i]; i++) { %} &lt;tr class="template-download fade"&gt; {% if (file.error) { %} &lt;td&gt;&lt;/td&gt; &lt;td class="name"&gt;&lt;span&gt;{%=file.name%}&lt;/span&gt;&lt;/td&gt; &lt;td class="size"&gt;&lt;span&gt;{%=o.formatFileSize(file.size)%}&lt;/span&gt;&lt;/td&gt; &lt;td class="error" colspan="2"&gt;&lt;span class="label label-important"&gt;{%=locale.fileupload.error%}&lt;/span&gt; {%=locale.fileupload.errors[file.error] || file.error%}&lt;/td&gt; {% } else { %} &lt;td class="preview"&gt;{% if (file.thumbnail_url) { %} &lt;a href="{%=file.url%}" title="{%=file.name%}" rel="gallery" download="{%=file.name%}"&gt;&lt;img src="{%=file.thumbnail_url%}"&gt;&lt;/a&gt; {% } %}&lt;/td&gt; &lt;td class="name"&gt; &lt;a href="{%=file.url%}" title="{%=file.name%}" rel="{%=file.thumbnail_url&amp;&amp;'gallery'%}" download="{%=file.name%}"&gt;{%=file.name%}&lt;/a&gt; &lt;/td&gt; &lt;td class="size"&gt;&lt;span&gt;{%=o.formatFileSize(file.size)%}&lt;/span&gt;&lt;/td&gt; &lt;td colspan="2"&gt;&lt;/td&gt; {% } %} &lt;td class="delete"&gt; &lt;button class="btn btn-danger" data-type="{%=file.delete_type%}" data-url="{%=file.delete_url%}"&gt; &lt;i class="icon-trash icon-white"&gt;&lt;/i&gt; &lt;span&gt;{%=locale.fileupload.destroy%}&lt;/span&gt; &lt;/button&gt; &lt;input type="checkbox" name="delete" value="1"&gt; &lt;/td&gt; &lt;/tr&gt; {% } %} &lt;/script&gt; &lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"&gt;&lt;/script&gt; &lt;!-- The jQuery UI widget factory, can be omitted if jQuery UI is already included --&gt; &lt;script src="&lt;?=base_url()?&gt;js/vendor/jquery.ui.widget.js"&gt;&lt;/script&gt; &lt;!-- The Templates plugin is included to render the upload/download listings --&gt; &lt;script src="http://blueimp.github.com/JavaScript-Templates/tmpl.min.js"&gt;&lt;/script&gt; &lt;!-- The Load Image plugin is included for the preview images and image resizing functionality --&gt; &lt;script src="http://blueimp.github.com/JavaScript-Load-Image/load-image.min.js"&gt;&lt;/script&gt; &lt;!-- The Canvas to Blob plugin is included for image resizing functionality --&gt; &lt;script src="http://blueimp.github.com/JavaScript-Canvas-to-Blob/canvas-to-blob.min.js"&gt;&lt;/script&gt; &lt;!-- Bootstrap JS and Bootstrap Image Gallery are not required, but included for the demo --&gt; &lt;script src="http://blueimp.github.com/cdn/js/bootstrap.min.js"&gt;&lt;/script&gt; &lt;script src="http://blueimp.github.com/Bootstrap-Image-Gallery/js/bootstrap-image-gallery.min.js"&gt;&lt;/script&gt; &lt;!-- The Iframe Transport is required for browsers without support for XHR file uploads --&gt; &lt;script src="&lt;?=base_url()?&gt;js/jquery.iframe-transport.js"&gt;&lt;/script&gt; &lt;!-- The basic File Upload plugin --&gt; &lt;script src="&lt;?=base_url()?&gt;js/jquery.fileupload.js"&gt;&lt;/script&gt; &lt;!-- The File Upload file processing plugin --&gt; &lt;script src="&lt;?=base_url()?&gt;js/jquery.fileupload-fp.js"&gt;&lt;/script&gt; &lt;!-- The File Upload user interface plugin --&gt; &lt;script src="&lt;?=base_url()?&gt;js/jquery.fileupload-ui.js"&gt;&lt;/script&gt; &lt;!-- The localization script --&gt; &lt;script src="&lt;?=base_url()?&gt;js/locale.js"&gt;&lt;/script&gt; &lt;!-- The main application script --&gt; &lt;script src="&lt;?=base_url()?&gt;js/main.js"&gt;&lt;/script&gt; </code></pre> <p>Here is the upload class that is in my helper folder of Codeigniter:</p> <pre><code> &lt;?php class UploadHandler { protected $options; function __construct($options=null) { $this-&gt;options = array( 'script_url' =&gt; $this-&gt;getFullUrl().'/', 'upload_dir' =&gt; dirname($_SERVER['SCRIPT_FILENAME']).'/files/', 'upload_url' =&gt; $this-&gt;getFullUrl().'/files/', 'param_name' =&gt; 'files', // Set the following option to 'POST', if your server does not support // DELETE requests. This is a parameter sent to the client: 'delete_type' =&gt; 'DELETE', // The php.ini settings upload_max_filesize and post_max_size // take precedence over the following max_file_size setting: 'max_file_size' =&gt; null, 'min_file_size' =&gt; 1, 'accept_file_types' =&gt; '/.+$/i', // The maximum number of files for the upload directory: 'max_number_of_files' =&gt; null, // Image resolution restrictions: 'max_width' =&gt; null, 'max_height' =&gt; null, 'min_width' =&gt; 1, 'min_height' =&gt; 1, // Set the following option to false to enable resumable uploads: 'discard_aborted_uploads' =&gt; true, // Set to true to rotate images based on EXIF meta data, if available: 'orient_image' =&gt; false, 'image_versions' =&gt; array( // Uncomment the following version to restrict the size of // uploaded images. You can also add additional versions with // their own upload directories: /* 'large' =&gt; array( 'upload_dir' =&gt; dirname($_SERVER['SCRIPT_FILENAME']).'/files/', 'upload_url' =&gt; $this-&gt;getFullUrl().'/files/', 'max_width' =&gt; 1920, 'max_height' =&gt; 1200, 'jpeg_quality' =&gt; 95 ), */ 'thumbnail' =&gt; array( 'upload_dir' =&gt; dirname($_SERVER['SCRIPT_FILENAME']).'/thumbnails/', 'upload_url' =&gt; $this-&gt;getFullUrl().'/thumbnails/', 'max_width' =&gt; 80, 'max_height' =&gt; 80 ) ) ); if ($options) { $this-&gt;options = array_replace_recursive($this-&gt;options, $options); } } protected function getFullUrl() { return (isset($_SERVER['HTTPS']) ? 'https://' : 'http://'). (isset($_SERVER['REMOTE_USER']) ? $_SERVER['REMOTE_USER'].'@' : ''). (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ($_SERVER['SERVER_NAME']. (isset($_SERVER['HTTPS']) &amp;&amp; $_SERVER['SERVER_PORT'] === 443 || $_SERVER['SERVER_PORT'] === 80 ? '' : ':'.$_SERVER['SERVER_PORT']))). substr($_SERVER['SCRIPT_NAME'],0, strrpos($_SERVER['SCRIPT_NAME'], '/')); } protected function set_file_delete_url($file) { $file-&gt;delete_url = $this-&gt;options['script_url'] .'?file='.rawurlencode($file-&gt;name); $file-&gt;delete_type = $this-&gt;options['delete_type']; if ($file-&gt;delete_type !== 'DELETE') { $file-&gt;delete_url .= '&amp;_method=DELETE'; } } protected function get_file_object($file_name) { $file_path = $this-&gt;options['upload_dir'].$file_name; if (is_file($file_path) &amp;&amp; $file_name[0] !== '.') { $file = new stdClass(); $file-&gt;name = $file_name; $file-&gt;size = filesize($file_path); $file-&gt;url = $this-&gt;options['upload_url'].rawurlencode($file-&gt;name); foreach($this-&gt;options['image_versions'] as $version =&gt; $options) { if (is_file($options['upload_dir'].$file_name)) { $file-&gt;{$version.'_url'} = $options['upload_url'] .rawurlencode($file-&gt;name); } } $this-&gt;set_file_delete_url($file); return $file; } return null; } protected function get_file_objects() { return array_values(array_filter(array_map( array($this, 'get_file_object'), scandir($this-&gt;options['upload_dir']) ))); } protected function create_scaled_image($file_name, $options) { $file_path = $this-&gt;options['upload_dir'].$file_name; $new_file_path = $options['upload_dir'].$file_name; list($img_width, $img_height) = @getimagesize($file_path); if (!$img_width || !$img_height) { return false; } $scale = min( $options['max_width'] / $img_width, $options['max_height'] / $img_height ); if ($scale &gt;= 1) { if ($file_path !== $new_file_path) { return copy($file_path, $new_file_path); } return true; } $new_width = $img_width * $scale; $new_height = $img_height * $scale; $new_img = @imagecreatetruecolor($new_width, $new_height); switch (strtolower(substr(strrchr($file_name, '.'), 1))) { case 'jpg': case 'jpeg': $src_img = @imagecreatefromjpeg($file_path); $write_image = 'imagejpeg'; $image_quality = isset($options['jpeg_quality']) ? $options['jpeg_quality'] : 75; break; case 'gif': @imagecolortransparent($new_img, @imagecolorallocate($new_img, 0, 0, 0)); $src_img = @imagecreatefromgif($file_path); $write_image = 'imagegif'; $image_quality = null; break; case 'png': @imagecolortransparent($new_img, @imagecolorallocate($new_img, 0, 0, 0)); @imagealphablending($new_img, false); @imagesavealpha($new_img, true); $src_img = @imagecreatefrompng($file_path); $write_image = 'imagepng'; $image_quality = isset($options['png_quality']) ? $options['png_quality'] : 9; break; default: $src_img = null; } $success = $src_img &amp;&amp; @imagecopyresampled( $new_img, $src_img, 0, 0, 0, 0, $new_width, $new_height, $img_width, $img_height ) &amp;&amp; $write_image($new_img, $new_file_path, $image_quality); // Free up memory (imagedestroy does not delete files): @imagedestroy($src_img); @imagedestroy($new_img); return $success; } protected function validate($uploaded_file, $file, $error, $index) { if ($error) { $file-&gt;error = $error; return false; } if (!$file-&gt;name) { $file-&gt;error = 'missingFileName'; return false; } if (!preg_match($this-&gt;options['accept_file_types'], $file-&gt;name)) { $file-&gt;error = 'acceptFileTypes'; return false; } if ($uploaded_file &amp;&amp; is_uploaded_file($uploaded_file)) { $file_size = filesize($uploaded_file); } else { $file_size = $_SERVER['CONTENT_LENGTH']; } if ($this-&gt;options['max_file_size'] &amp;&amp; ( $file_size &gt; $this-&gt;options['max_file_size'] || $file-&gt;size &gt; $this-&gt;options['max_file_size']) ) { $file-&gt;error = 'maxFileSize'; return false; } if ($this-&gt;options['min_file_size'] &amp;&amp; $file_size &lt; $this-&gt;options['min_file_size']) { $file-&gt;error = 'minFileSize'; return false; } if (is_int($this-&gt;options['max_number_of_files']) &amp;&amp; ( count($this-&gt;get_file_objects()) &gt;= $this-&gt;options['max_number_of_files']) ) { $file-&gt;error = 'maxNumberOfFiles'; return false; } list($img_width, $img_height) = @getimagesize($uploaded_file); if (is_int($img_width)) { if ($this-&gt;options['max_width'] &amp;&amp; $img_width &gt; $this-&gt;options['max_width'] || $this-&gt;options['max_height'] &amp;&amp; $img_height &gt; $this-&gt;options['max_height']) { $file-&gt;error = 'maxResolution'; return false; } if ($this-&gt;options['min_width'] &amp;&amp; $img_width &lt; $this-&gt;options['min_width'] || $this-&gt;options['min_height'] &amp;&amp; $img_height &lt; $this-&gt;options['min_height']) { $file-&gt;error = 'minResolution'; return false; } } return true; } protected function upcount_name_callback($matches) { $index = isset($matches[1]) ? intval($matches[1]) + 1 : 1; $ext = isset($matches[2]) ? $matches[2] : ''; return ' ('.$index.')'.$ext; } protected function upcount_name($name) { return preg_replace_callback( '/(?:(?: \(([\d]+)\))?(\.[^.]+))?$/', array($this, 'upcount_name_callback'), $name, 1 ); } protected function trim_file_name($name, $type, $index) { // Remove path information and dots around the filename, to prevent uploading // into different directories or replacing hidden system files. // Also remove control characters and spaces (\x00..\x20) around the filename: $file_name = trim(basename(stripslashes($name)), ".\x00..\x20"); // Add missing file extension for known image types: if (strpos($file_name, '.') === false &amp;&amp; preg_match('/^image\/(gif|jpe?g|png)/', $type, $matches)) { $file_name .= '.'.$matches[1]; } if ($this-&gt;options['discard_aborted_uploads']) { while(is_file($this-&gt;options['upload_dir'].$file_name)) { $file_name = $this-&gt;upcount_name($file_name); } } return $file_name; } protected function handle_form_data($file, $index) { // Handle form data, e.g. $_REQUEST['description'][$index] } protected function orient_image($file_path) { $exif = @exif_read_data($file_path); if ($exif === false) { return false; } $orientation = intval(@$exif['Orientation']); if (!in_array($orientation, array(3, 6, 8))) { return false; } $image = @imagecreatefromjpeg($file_path); switch ($orientation) { case 3: $image = @imagerotate($image, 180, 0); break; case 6: $image = @imagerotate($image, 270, 0); break; case 8: $image = @imagerotate($image, 90, 0); break; default: return false; } $success = imagejpeg($image, $file_path); // Free up memory (imagedestroy does not delete files): @imagedestroy($image); return $success; } protected function handle_file_upload($uploaded_file, $name, $size, $type, $error, $index) { $file = new stdClass(); $file-&gt;name = $this-&gt;trim_file_name($name, $type, $index); $file-&gt;size = intval($size); $file-&gt;type = $type; if ($this-&gt;validate($uploaded_file, $file, $error, $index)) { $this-&gt;handle_form_data($file, $index); $file_path = $this-&gt;options['upload_dir'].$file-&gt;name; $append_file = !$this-&gt;options['discard_aborted_uploads'] &amp;&amp; is_file($file_path) &amp;&amp; $file-&gt;size &gt; filesize($file_path); clearstatcache(); if ($uploaded_file &amp;&amp; is_uploaded_file($uploaded_file)) { // multipart/formdata uploads (POST method uploads) if ($append_file) { file_put_contents( $file_path, fopen($uploaded_file, 'r'), FILE_APPEND ); } else { move_uploaded_file($uploaded_file, $file_path); } } else { // Non-multipart uploads (PUT method support) file_put_contents( $file_path, fopen('php://input', 'r'), $append_file ? FILE_APPEND : 0 ); } $file_size = filesize($file_path); if ($file_size === $file-&gt;size) { if ($this-&gt;options['orient_image']) { $this-&gt;orient_image($file_path); } $file-&gt;url = $this-&gt;options['upload_url'].rawurlencode($file-&gt;name); foreach($this-&gt;options['image_versions'] as $version =&gt; $options) { if ($this-&gt;create_scaled_image($file-&gt;name, $options)) { if ($this-&gt;options['upload_dir'] !== $options['upload_dir']) { $file-&gt;{$version.'_url'} = $options['upload_url'] .rawurlencode($file-&gt;name); } else { clearstatcache(); $file_size = filesize($file_path); } } } } else if ($this-&gt;options['discard_aborted_uploads']) { unlink($file_path); $file-&gt;error = 'abort'; } $file-&gt;size = $file_size; $this-&gt;set_file_delete_url($file); } return $file; } public function get() { $file_name = isset($_REQUEST['file']) ? basename(stripslashes($_REQUEST['file'])) : null; if ($file_name) { $info = $this-&gt;get_file_object($file_name); } else { $info = $this-&gt;get_file_objects(); } header('Content-type: application/json'); echo json_encode($info); } public function post() { if (isset($_REQUEST['_method']) &amp;&amp; $_REQUEST['_method'] === 'DELETE') { return $this-&gt;delete(); } $upload = isset($_FILES[$this-&gt;options['param_name']]) ? $_FILES[$this-&gt;options['param_name']] : null; $info = array(); if ($upload &amp;&amp; is_array($upload['tmp_name'])) { // param_name is an array identifier like "files[]", // $_FILES is a multi-dimensional array: foreach ($upload['tmp_name'] as $index =&gt; $value) { $info[] = $this-&gt;handle_file_upload( $upload['tmp_name'][$index], isset($_SERVER['HTTP_X_FILE_NAME']) ? $_SERVER['HTTP_X_FILE_NAME'] : $upload['name'][$index], isset($_SERVER['HTTP_X_FILE_SIZE']) ? $_SERVER['HTTP_X_FILE_SIZE'] : $upload['size'][$index], isset($_SERVER['HTTP_X_FILE_TYPE']) ? $_SERVER['HTTP_X_FILE_TYPE'] : $upload['type'][$index], $upload['error'][$index], $index ); } } elseif ($upload || isset($_SERVER['HTTP_X_FILE_NAME'])) { // param_name is a single object identifier like "file", // $_FILES is a one-dimensional array: $info[] = $this-&gt;handle_file_upload( isset($upload['tmp_name']) ? $upload['tmp_name'] : null, isset($_SERVER['HTTP_X_FILE_NAME']) ? $_SERVER['HTTP_X_FILE_NAME'] : (isset($upload['name']) ? $upload['name'] : null), isset($_SERVER['HTTP_X_FILE_SIZE']) ? $_SERVER['HTTP_X_FILE_SIZE'] : (isset($upload['size']) ? $upload['size'] : null), isset($_SERVER['HTTP_X_FILE_TYPE']) ? $_SERVER['HTTP_X_FILE_TYPE'] : (isset($upload['type']) ? $upload['type'] : null), isset($upload['error']) ? $upload['error'] : null ); } header('Vary: Accept'); $json = json_encode($info); $redirect = isset($_REQUEST['redirect']) ? stripslashes($_REQUEST['redirect']) : null; if ($redirect) { header('Location: '.sprintf($redirect, rawurlencode($json))); return; } if (isset($_SERVER['HTTP_ACCEPT']) &amp;&amp; (strpos($_SERVER['HTTP_ACCEPT'], 'application/json') !== false)) { header('Content-type: application/json'); } else { header('Content-type: text/plain'); } echo $json; } public function delete() { $file_name = isset($_REQUEST['file']) ? basename(stripslashes($_REQUEST['file'])) : null; $file_path = $this-&gt;options['upload_dir'].$file_name; $success = is_file($file_path) &amp;&amp; $file_name[0] !== '.' &amp;&amp; unlink($file_path); if ($success) { foreach($this-&gt;options['image_versions'] as $version =&gt; $options) { $file = $options['upload_dir'].$file_name; if (is_file($file)) { unlink($file); } } } header('Content-type: application/json'); echo json_encode($success); } } </code></pre> <p>Any idea, any help will be very helpful. Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload