I am using uploadify and my problem is that the files are not uploading.
This is my code:
On uploadify.php I've set the root path to: /
Like this:
$targetFolder = '/'; // Relative to the root
Then the rest on the script:
<script type="text/javascript">
jQuery(document).ready(function() {
$('#file_upload').uploadify({
'uploader' : '/myIncludes/UploadiftyFolder/uploadify.php',
'swf' : '/myIncludes/UploadiftyFolder/uploadify.swf',
'cancelImg' : '/myIncludes/UploadiftyFolder/cancel.png',
'folder' : '/myUploads/UploadsDirectory/images/',
'auto' : true,
'multi' : false,
'checkExisting' : false
});
});
</script>
//Finally
<input id="file_upload" type="file" name="Filedata" />
Upload Files
When I try to upload an image it all works well (seems too) and it says - Complete ...
But nothing is being uploaded.
Any ideas?
UPDATE:
Here are my server structure paths:
My Paths:
root/myIncludes/UploadiftyFolder/ <--Here are all the uploadify files
root/myUploads/UploadsDirectory/images/ <--Here is where I need to upload
Here are my current settings on uploadify:
folder --> '/myUploads/UploadsDirectory/images/',
and in uploadify.php --> $targetFolder = '/'; // Relative to the root
Here is the rest of the uploadify.php file ... I haven't changed anything there:
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
$targetFile = rtrim($targetPath,'/') . $_FILES['Filedata']['name'];
// Validate the file type
$fileTypes = array('jpg','jpeg','gif','png'); // File extensions
$fileParts = pathinfo($_FILES['Filedata']['name']);
if (in_array($fileParts['extension'],$fileTypes)) {
move_uploaded_file($tempFile,$targetFile);
echo '1';
} else {
echo 'Invalid file type.';
}
}
For me, the problem was in the uploadify.php file. They are using:
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
$targetFile = rtrim($targetPath,'/') . '/' . $_FILES['Filedata']['name'];
$targetFolder is defined by you at the top.
and then later:
move_uploaded_file($tempFile,$targetFile);
The default example appends the target folder to the end of $_SERVER['DOCUMENT_ROOT']. My $_SERVER['DOCUMENT_ROOT'] was actually C:\xampp\htdocs. So, to make it work your target folder would have to be:
$targetFolder = "/yourSiteFolder/wherever/your/upload/folder/is";
What I did:
Got rid of $_SERVER['DOCUMENT_ROOT'] altogether. Here is my uploadify.php file:
<?php
/*
Uploadify v3.1.0
Copyright (c) 2012 Reactive Apps, Ronnie Garcia
Released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/
// Define a destination
//$targetFolder = '/sandbox/uploads'; // Relative to the root
if (!empty($_FILES)) {
//$tempFile = $_FILES['Filedata']['tmp_name'];
//$targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
//$targetFile = rtrim($targetPath,'/') . '/' . $_FILES['Filedata']['name'];
// Validate the file type
$fileTypes = array('jpg','jpeg','gif','png'); // File extensions
$fileParts = pathinfo($_FILES['Filedata']['name']);
if (in_array($fileParts['extension'],$fileTypes)) {
move_uploaded_file($_FILES["Filedata"]["tmp_name"], "uploads/" . $_FILES["Filedata"]["name"]);
echo '1';
} else {
echo 'Invalid file type.';
}
}
?>
The major change is that I've replaced this:
move_uploaded_file($tempFile,$targetFile);
with this:
move_uploaded_file($_FILES["Filedata"]["tmp_name"], "uploads/" . $_FILES["Filedata"]["name"]);
And then commented out several lines that weren't needed anymore.
And this is my check-exists.php file:
<?php
/*
Uploadify v3.1.0
Copyright (c) 2012 Reactive Apps, Ronnie Garcia
Released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/
// Define a destination
//$targetFolder = 'uploads'; // Relative to the root and should match the upload folder in the uploader script
if (file_exists("uploads/" . $_POST['filename'])) {
echo 1;
} else {
echo 0;
}
?>
And this is my jquery code:
$(function() {
$("#uploadify").uploadify({
height : 30,
swf : 'uploadify/uploadify.swf',
uploader : 'uploadify/uploadify.php',
width : 120
});
});
A note about the file structure of my site:
All the uploadify files are in the root of my site in a folder called uploadify. Within uploadify is a folder called uploads and this is where the files are uploaded.
Hope that helps.
I tried all of the other suggestions here, but none of them worked for me. Then I realized that version 3.2 of Uploadify (and maybe previous versions, too) requires a timestamp and hashed token in order to complete the upload.
First off, I had to move the script from an external JS file to my PHP file so that I could get the timestamp from PHP. (You could also do this via a hidden input value or other method, but this was the simplest way.) Then I had to add the 'formData' option to my Uploadify call along with some PHP code that gets the timestamp and hashes it with a unique salt (which you should change to a random string):
<?php $timestamp = time();?>
<script>
$('#file_upload').uploadify({
'swf' : '/uploadify/uploadify.swf',
'uploader' : '/uploadify/uploadify.php',
'formData' : {
'timestamp' : '<?php echo $timestamp;?>',
'token' : '<?php echo md5("unique_salt" . $timestamp);?>'
}
});
</script>
Although this code seems to be required in version 3.2, it is not mentioned in the implementation documentation. I had to look in the index.php file that came in the download package to find it.
Try giving "~/" before uploads folder
(Or) here is the entire script:
<script type="text/javascript">
$(window).load(
function () {
$("#fileInput1").uploadify({
'uploader': 'scripts/uploadify.swf',
'cancelImg': 'images/cancel.png',
'buttonText': 'Browse Files',
'script': 'UploadVB.ashx',
'folder': 'uploads',
'fileDesc': 'Image Files',
'fileExt': '*.jpg;*.jpeg;*.gif;*.png',
'queueSizeLimit': 9999,
'simUploadLimit': 2,
'sizeLimit': 4000000,
'multi': true,
'auto': true,
'onComplete': function (event, queueID, fileObj, response, data) {
$("#thumbnail").append(response)
},
'onError': function (event, ID, fileObj, errorObj) {
alert(errorObj.type + ' Error: ' + errorObj.info);
}
});
}
);
</script>
For me, all I had to do was get rid of $_SERVER['DOCUMENT_ROOT'] in the $targetPath definition. And then I also used "uploads" instead of "/uploads" as my $targetFolder.
Related
My website has a drawing tool. This drawing tool help met create an image (.png) from the drawing. Has been working for years now, but recently changed the wordpress theme.
Now I can't figure out what's going wrong.
I have the following code which is doing a POST request to a file in my theme folder
var templateUrl = 'https://example.nl/wp-content/themes/generatepress';
var strDataURI = canvas.toDataURL("image/jpg",'',1.0);
var jsnDataJSON = encodeURIComponent(JSON.stringify(canvas));
$('input[name=json]').val(jsnDataJSON);
strDataURI = strDataURI.substr(22, strDataURI.length);
var ajax_urll= templateUrl+"/ajax.php";
$.post(ajax_urll,
{
str: strDataURI
},
function(data){
var obj=jQuery.parseJSON(data);
if(obj.status!="ERROR"){
jQuery("#drawing").html(obj.image);
jQuery("#drawingsaveresult").html("Drawing has been successfully saved");
jQuery("#drawingsaveresult").fadeOut(10000);
jQuery("input[name='drawing']").val(obj.imagename);
}else{
jQuery("#drawingsaveresult").html("Else error in saving drawing");
jQuery("#drawingsaveresult").fadeOut(10000);
}
});
So this code is calling ajax.php file (file in theme folder) which does the following
<?php
session_start();
// require_once( $_SERVER['DOCUMENT_ROOT'] . '/example.nl/wp-load.php' ); localhost
require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php' );
global $wpdb;
$data = base64_decode($_POST["str"]);
$urlUploadImages = "oefeningen/";
$nameImage = rand()."drawing.png";
$img = imagecreatefromstring($data);
imageAlphaBlending($img, true);
imageSaveAlpha($img, true);
$response=array();
if($img) {
imagepng($img, $urlUploadImages.$nameImage, 0);
imagedestroy($img);
get_stylesheet_directory_uri();
$response['image']="<img src='".get_stylesheet_directory_uri()."/oefeningen/".$nameImage."' width=100 height=150>";
$response['imagename']=$nameImage;
$response['status']="success";
}
else {
$response['status']="ERROR";
}
echo json_encode($response);
But for some reason it's not working anymore. In the console it's giving the following error back
POST https://example.nl/wp-content/themes/generatepress/ajax.php 500
I can't find a resolution. Can someone assist me with this?
I have integrated summernote in my website (built with Codeigniter) and for texts it is working fine. But for image upload, there arises the following problem.
Summernote reads the image as base64. Now this works perfectly fine for small images, but once images are large, the image finally does not render due to the huge string created by the base64 in the database.
So I am trying to save the image in my server and then use the link of that image.
Following are the codes:
Script for summernote:
<script type="text/javascript">
$(document).ready(function() {
$('#summernote').summernote({
height: 300,
onImageUpload: function(files) {
sendFile(files[0]);
}
});
function sendFile(file) {
data = new FormData();
data.append("files", file);
upload_url = "<?php echo base_url(); ?>" + "general/upload_image";
$.ajax({
data: data,
type: "POST",
url: upload_url,
cache: false,
contentType: false,
processData: false,
success: function(url) {
$(this).summernote("insertImage", url);
}
});
}
});
the php upload_image function:
public function upload_image()
{
if ($_FILES['file']['name']) {
if (!$_FILES['file']['error']) {
$name = md5(rand(100, 200));
$ext = explode('.', $_FILES['file']['name']);
$filename = $name . '.' . $ext[1];
$destination = 'http://sitename.com/dist/img/blogimg/' . $filename; //change this directory
$location = $_FILES["file"]["tmp_name"];
move_uploaded_file($location, $destination);
echo 'http://sitename.com/dist/img/blogimg/' . $filename;//change this URL
}
else
{
echo $message = 'Ooops! Your upload triggered the following error: '.$_FILES['file']['error'];
}
}
}
now, when I click on insert image in summernote or drag and drop an image multiple instances of the following error is shown in the console:
>Uncaught TypeError: Cannot read property 'nodeType' of undefined
This is what I want to achieve,
N.B. This editor is for a blog.
1. User clicks on insert image and uploads an image from his computer.
2. the image is shown in the editor (but not uploaded to server at this step).
3. When user clicks on submit button, then the image should be saved as an image file in a predefined folder.
4. When the page renders the it should have
<img src="mysite.com/path_to_image">
now it is something like
<img src="data:image/jpeg;base64,/9j/4AAQSkZJR....">)
Please note, I tried using onImageUpload within callbacks but the result was nothing was actually happening, neither the image was geting uploaded to the editor nor to the folder in the server.
Where am I going wrong....?? Please help me fix this...
if your summernote version after 0.7
following this
$('#summernote').summernote({
height: 400,
callbacks: {
onImageUpload: function(files, editor, welEditable) {
sendFile(files[0]);
}
}});
Okay, although I could not find a solution to my problem, I have implemented an alternation solution and it works perfectly, although pt. 3 is not catered to and the image is uploaded to the server in an earlier step. That too can be catered with some js scripts...Will do that later... What I did is I targeted the summernote ids and classes and added my codes in place of theirs...
I removed their upload image field by this code:
<style>
/*to disable the upload image from computer uncomment this css code.*/
.note-group-select-from-files {
display: none;
}
</style>
Next I inserted my HTML below their insert link field this way:
document.getElementsByClassName('note-group-image-url')[0].insertAdjacentHTML('afterend','<p class="sober"><p>Click here to upoad image</p></i></p>');
Next I handled the image upload through a modal and wrote a custom js script that copied the image url to the field of .note-image-url
Also I had to customise the javascript of the insert image button of summernote with js so that users can directly click on insert image.
You can add this to your store/ update controller.
It will detect images in your editor, convert and save it in your server.
$body = $data['content'];
$doc = new DomDocument;
libxml_use_internal_errors(true);
$doc->loadHTML($body);
$images = $doc->getelementsbytagname('img');
define('UPLOAD_DIR', 'assets/images/announcement_img/');
foreach($images as $k => $img){
$datas = $img->getattribute('src');
if (strpos($datas, 'data:image')!==false){
list($type, $datas) = explode(';', $datas);
list($media, $format) = explode('/', $type);
list(, $datas) = explode(',', $datas);
$datas = str_replace(' ', '+', $datas);
$datas = base64_decode($datas);
$file= UPLOAD_DIR . time().$k.'.'.$format;
$success = file_put_contents($file, $datas);
print $success ? $file : '<br><br>Unable to save the file.<br><br>';
$img->removeattribute('src');
$img->setattribute('src',base_url().$file);
}
}
$body = $doc->savehtml();
$data['content']=$body;
I am very new to javascript and ajax and I would like to do the folowing:
I have got a page where you can select the name of the person you want to upload a file. Then, through javascript you get that name in a variable and through ajax you pass the variable to a .php file where the upload takes place. The problem is that no name is passed and the file is upload in the same folder where all the names of the people are, not inside one of them. Here is the code I have got for the moment:
SOME NEW EDITS IN THE CODE
html
<select id="cuadro" name="op-cliente">
<option>bbraun</option>
<option>biosystems</option>
<option>seat</option>
<option>tradsp</option>
<option>tradin</option>
<option>vanderlande</option>
</select>
<script type="text/javascript">
$(function() {
// Setup html5 version
$("#uploader").pluploadQueue({
// General settings
runtimes : 'html5,flash,silverlight,html4',
url : 'plupload/examples/upload.php',
multipart_params: {'valor' : $('#cuadro').val()},
chunk_size: '5mb',
rename : true,
dragdrop: true,
filters : {
// Maximum file size
max_file_size : '500mb',
// Specify what files to browse for
mime_types: [
]
},
flash_swf_url : 'plupload/js/Moxie.swf',
silverlight_xap_url : 'plupload/js/Moxie.xap'
});
});
</script>
php
$valor = $_REQUEST['valor'];
$targetDir = ".." . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "uploads" . DIRECTORY_SEPARATOR . $valor;
$cleanupTargetDir = true; // Remove old files
$maxFileAge = 7 * 24 * 3600; // Temp file age in seconds
// Create target dir
if (!file_exists($targetDir)) {
#mkdir($targetDir);
}
// Get a file name
if (isset($_REQUEST["name"])) {
$fileName = $_REQUEST["name"];
} elseif (!empty($_FILES)) {
$fileName = $_FILES["file"]["name"];
} else {
$fileName = uniqid("file_");
}
$filePath = $targetDir . DIRECTORY_SEPARATOR . $fileName;
// Chunking might be enabled
$chunk = isset($_REQUEST["chunk"]) ? intval($_REQUEST["chunk"]) : 0;
$chunks = isset($_REQUEST["chunks"]) ? intval($_REQUEST["chunks"]) : 0;
// Remove old temp files
if ($cleanupTargetDir) {
if (!is_dir($targetDir) || !$dir = opendir($targetDir)) {
die('{"jsonrpc" : "2.0", "error" : {"code": 100, "message": "Failed to open temp directory."}, "id" : "id"}');
}
while (($file = readdir($dir)) !== false) {
$tmpfilePath = $targetDir . DIRECTORY_SEPARATOR . $file;
// If temp file is current file proceed to the next
if ($tmpfilePath == "{$filePath}.part") {
continue;
}
// Remove temp file if it is older than the max age and is not the current file
if (preg_match('/\.part$/', $file) && (filemtime($tmpfilePath) < time() - $maxFileAge)) {
#unlink($tmpfilePath);
}
}
closedir($dir);
}
And this last time I got something that could be revealing: if I change this: multipart_params: {'valor' : $('#cuadro').val()}, to this: multipart_params: {'valor' : '5'}, it works and creates a folder called "5"....
Thank you very much for your time
I see you're passing it as a GET value. Therefore the variable is not in the POST.
Change
$_POST['valor']; to $_GET['valor'];
An Alternative
<select id="cuadro" name="op-cliente">
<option>bbraun</option>
<option>biosystems</option>
<option>seat</option>
<option>tradsp</option>
<option>tradin</option>
<option>vanderlande</option>
</select>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script type="text/javascript">
$('#cuadro').change(function(){
var selectedValue = $("#cuadro").val();
$.ajax({url:"plupload/examples/upload.php?valor="+selectedValue,cache:false,success:function(result){
alert("success");
}});
});
</script>
upload.php (For this way, use $_GET to get valor.)
$targetDir = ".." . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR .
"uploads" . DIRECTORY_SEPARATOR . $_GET['valor'];
the problem i think you face is because you send the name of the person in one request and the file in an other request but if you send them in the same request you will get the wanted result i have tested this and it works for me.
this is index.php
<html>
<head>
<script type="text/javascript" src="jquery-1.12.0.js"></script>
<script type="text/javascript">
$(function(){
$('#my_Form').on('submit',function(e){
e.preventDefault();
var $form=$(this);
var fd = (window.FormData)? new FormData($form[0]) : null;
var data=(fd !==null)? fd : $form.serialize();
$.ajax($form.attr('action'),{
type:$form.attr('method'),
contentType:false,
processData:false,
dataType:'json',
data:data,
success:function(response){alert("sucess");},
error:function(response){alert("update failre");}
});
});
});
</script>
</head>
<body>
<form id="my_Form" action="upload.php" method="POST" enctype="multipart/form-data">
<fieldset>
<select name="person" >
<option value="jhon">jhnon</option>
<option value="albert">albert</option>
<option value="achabahe">achabahe</option>
<option value="Tom">Tom</option>
</select>
<input type="file" name="myFile"/>
<input type="submit" value="Upload"/>
</fieldset>
</form>
</body>
</html>
and this is upload.php
<?php
$tempFile=$_FILES['myFile']['tmp_name'];
$targetDir = ".." . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "uploads" . DIRECTORY_SEPARATOR . $_POST['person'];
$uploadedFileName= $_FILES['myFile']['name'];
$maxFileAge=7*24*3600;
$cleanUpTargetDir=true;
if(!file_exists($targetDir)){
#mkdir($targetDir);
}
if($dir=opendir($targetDir)){
while($file=readdir($dir)) {
$file=$targetDir.DIRECTORY_SEPARATOR.$file;
if(filemtime($file)<(time() - $maxFileAge )){
#unlink($file);
}
}
}else{
die('{"jsonrpc" : "2.0", "error" : {"code": 100, "message": "Failed to open temp directory."}, "id" : "id"}');
}
$filePath= $targetDir . DIRECTORY_SEPARATOR .$uploadedFileName;
move_uploaded_file($tempFile,$filePath);
?>
I am using some jquery to help upload a file to a php script. Everything is working fine and the file does in fact get uploaded. But during the upload, I have made it so the file gets resized to our needs, with a new unique file name. I'd like to pass that new unique file name back to the jquery and have it display on the page. Right now, it just displays the original image (which is not resized)
Here's the jquery code:
$(function(){
var btnUpload=$('#upload');
var status=$('#status');
new AjaxUpload(btnUpload, {
action: 'upload-file.php',
name: 'uploadfile',
onSubmit: function(file, ext){
if (! (ext && /^(jpg|png|jpeg|gif)$/.test(ext))){
// extension is not allowed
status.text('Only JPG, PNG or GIF files are allowed');
return false;
}
status.text('Uploading...');
},
onComplete: function(file, response){
//On completion clear the status
status.text('');
//Add uploaded file to list
if(response==="success"){
$('<li></li>').appendTo('#files').html('<img src="./uploads/'+file+'" alt="" /><br />'+file).addClass('success');
} else{
$('<li></li>').appendTo('#files').text(file).addClass('error');
}
}
});
});
And then my upload php file looks like this:
$uploaddir = 'uploads';
$file = $uploaddir . basename($_FILES['uploadfile']['name']);
if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $file)) {
$path = realpath(dirname(__FILE__));
include $path . '/uploads/phmagick.php';
$temp_file = explode(".", $_FILES['uploadfile']['name']);
$time = time();
$new_file = $time . '.' . $temp_file[1];
$p = new phmagick($path . '/uploads/' . $_FILES['uploadfile']['name'], $path . '/uploads/' . $new_file);
$p->convert();
$phMagick = new phMagick($path . '/uploads/' . $new_file, $path . '/uploads/' . $new_file);
$phMagick->debug=true;
$phMagick->resize(414,414,true);
echo "success";
} else {
echo "error";
}
Any thoughts on how I can get the new unique file name back, which would be something like: 1397413326.jpg?
Thank you
Echo the filename back instead of the word "success".
I have started from scratch to develop a theme, now i have a code snippet from one websites where in he is using the script like -
<script>
head.js(
{ jquery : "js/jquery.min.js" },
{ mousewheel : "js/jquery.mousewheel.js" },
{ mwheelIntent : "js/mwheelIntent.js" },
{ jScrollPane : "js/jquery.jscrollpane.min.js" },
{ history : "js/jquery.history.js" },
{ stringLib : "js/core.string.js" },
{ easing : "js/jquery.easing.1.3.js" },
{ smartresize : "js/jquery.smartresize.js" },
{ page : "js/jquery.page.js" }
);
</script>
Now i when i try this in my category-{slug}.php it searches these files in the folder wordpress/category/{slug}/
Now i also tried here `
<script>
head.js(
{ jquery : "<?php bloginfo('template_url')?>/js/jquery.min.js" },
{ mousewheel : "<?php bloginfo('template_url')?>/js/jquery.mousewheel.js" },
{ mwheelIntent : "<?php bloginfo('template_url')?>/js/mwheelIntent.js" },
{ jScrollPane : "<?php bloginfo('template_url')?>/js/jquery.jscrollpane.min.js" },
{ history : "<?php bloginfo('template_url')?>/js/jquery.history.js" },
{ stringLib : "<?php bloginfo('template_url')?>/js/core.string.js" },
{ easing : "js/jquery.easing.1.3.js" },
{ smartresize : "<?php bloginfo('template_url')?>/js/jquery.smartresize.js" },
{ page : "<?php bloginfo('template_url')?>/js/jquery.page.js" }
);`
</script>
Then also i get a 404 error in firebug but when i try something like this -
{jquery : "../../wp-content/themes/testing/js/literature"},
It works, Now i wanted to know that why it is looking these dependancies in the folder category rather than my theme directory whereas at the same time if i wrote these lines
<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/literature/head.min.js"></script>
in my head section and to my surprise they work, can anyone tell me what is going on here
Accordingly to your code, you're using a script called head.js, which allows you to add more scripts to your header. If you truly want to use head.js, you have to add that script in your head manually. I discourage using what you don't really need.
Put this PHP code in your functions.php file, which should be located in your theme directory. If not, create it. This is how you usually include scripts to your theme.
add_action('wp_enqueue_scripts', 'mytheme_enqueue_scripts');
function mytheme_enqueue_scripts() {
// jQuery comes with WordPress, no need to include it
$dir = get_stylesheet_directory_uri() . '/js';
// Vanilla scripts
wp_enqueue_scripts('stringLib', $dir . '/core.string.js');
// All these guys depend on jQuery, hence the "array('jquery')"
wp_enqueue_scripts('easing', $dir . '/jquery.easing.1.3.js', array('jquery'));
wp_enqueue_scripts('easing', $dir . '/jquery.smartresize.js', array('jquery'));
wp_enqueue_scripts('easing', $dir . '/jquery.page.js', array('jquery'));
wp_enqueue_scripts('history', $dir . '/jquery.history.js', array('jquery'));
wp_enqueue_scripts('mousewheel', $dir . '/jquery.mousewheel.js', array('jquery'));
wp_enqueue_scripts('mwheelintent', $dir . '/jquery.easing.1.3.js', array('jquery'));
wp_enqueue_scripts('mwheelintent', $dir . '/mwheelIntent.js', array('jquery'));
wp_enqueue_scripts('jscrollpane', $dir . '/jquery.jscrollpane.min.js', array('jquery'));
// This one happens to rely on jScrollPane
wp_enqueue_scripts('mwheelintent', $dir . '/mwheelIntent.js', array('jscrollpane'));
}
PS. Don't forget that PHP code always starts with <?php
Is wp-blog-header.php loaded before you load category-{slug}.php?