0

I'm using the jquery library blueimp upload. I want to upload images to a different directory. I just modified the /server/php/index.php file (only this file) :

error_reporting(E_ALL | E_STRICT);
require_once('UploadHandler.php');

//$upload_handler = new UploadHandler();
define(DIR_DOWNLOAD, "/Applications/XAMPP/htdocs/villalba2");
define(HTTP_SERVER, "localhost/villalba2");

$blogId= "Mobiliario";
$upload_handler =   new UploadHandler(array(
            'upload_dir' => DIR_DOWNLOAD . '/uploads/' . $blogId. '/',
            'upload_url' => HTTP_SERVER . '/uploads/' . $blogId. '/', 
));

the permission folder are 777

The images are loaded correctly in the directory that i want, but I get this error:

Chrome ->SyntaxError: Unexpected token <
Safari ->SyntaxError: JSON Parse error: Unrecognized token '<'

The result of /server/php/index.php is:

<b>Notice</b>:  Use of undefined constant DIR_DOWNLOAD - assumed 'DIR_DOWNLOAD' in <b>/Applications/XAMPP/xamppfiles/htdocs/villalba2/up/server/php/index.php</b> on line <b>16</b><br />
<br />
<b>Notice</b>:  Use of undefined constant HTTP_SERVER - assumed 'HTTP_SERVER' in <b>/Applications/XAMPP/xamppfiles/htdocs/villalba2/up/server/php/index.php</b> on line <b>17</b><br />


{"files":[{"name":"cama (1).jpg","size":101775,"url":"localhost\/villalba2\/uploads\/Mobiliario\/cama%20%281%29.jpg","thumbnailUrl":"localhost\/villalba2\/uploads\/Mobiliario\/thumbnail\/cama%20%281%29.jpg","deleteUrl":"http:\/\/localhost\/villalba2\/up\/server\/php\/?file=cama%20%281%29.jpg","deleteType":"DELETE"},{"name":"cama (2).jpg","size":101775,"url":"localhost\/villalba2\/uploads\/Mobiliario\/cama%20%282%29.jpg","thumbnailUrl":"localhost\/villalba2\/uploads\/Mobiliario\/thumbnail\/cama%20%282%29.jpg","deleteUrl":"http:\/\/localhost\/villalba2\/up\/server\/php\/?file=cama%20%282%29.jpg","deleteType":"DELETE"},{"name":"cama (3).jpg","size":101775,"url":"localhost\/villalba2\/uploads\/Mobiliario\/cama%20%283%29.jpg","thumbnailUrl":"localhost\/villalba2\/uploads\/Mobiliario\/thumbnail\/cama%20%283%29.jpg","deleteUrl":"http:\/\/localhost\/villalba2\/up\/server\/php\/?file=cama%20%283%29.jpg","deleteType":"DELETE"},{"name":"cama.jpg","size":101775,"url":"localhost\/villalba2\/uploads\/Mobiliario\/cama.jpg","thumbnailUrl":"localhost\/villalba2\/uploads\/Mobiliario\/thumbnail\/cama.jpg","deleteUrl":"http:\/\/localhost\/villalba2\/up\/server\/php\/?file=cama.jpg","deleteType":"DELETE"},{"name":"mantelera.jpg","size":50986,"url":"localhost\/villalba2\/uploads\/Mobiliario\/mantelera.jpg","thumbnailUrl":"localhost\/villalba2\/uploads\/Mobiliario\/thumbnail\/mantelera.jpg","deleteUrl":"http:\/\/localhost\/villalba2\/up\/server\/php\/?file=mantelera.jpg","deleteType":"DELETE"},{"name":"test (1).png","size":15,"url":"localhost\/villalba2\/uploads\/Mobiliario\/test%20%281%29.png","deleteUrl":"http:\/\/localhost\/villalba2\/up\/server\/php\/?file=test%20%281%29.png","deleteType":"DELETE"},{"name":"test (2).png","size":15,"url":"localhost\/villalba2\/uploads\/Mobiliario\/test%20%282%29.png","deleteUrl":"http:\/\/localhost\/villalba2\/up\/server\/php\/?file=test%20%282%29.png","deleteType":"DELETE"},{"name":"test.png","size":15,"url":"localhost\/villalba2\/uploads\/Mobiliario\/test.png","deleteUrl":"http:\/\/localhost\/villalba2\/up\/server\/php\/?file=test.png","deleteType":"DELETE"}]}

Why dosen't work?? the images are upload in the correct folder :S

Thanks!

---THIS LAST PART IS SOLVED-----

Edit:

Now the the thumbs are not displayed on the browser..

Failed to load resource: the server responded with a status of 404 (Not Found) /localhost/villalba2/up/localhost/villalba2/uploads/Mobiliario/thumbnail/mbiliario.jpg

the correct absolute path it will be:

/localhost/villalba2/uploads/Mobiliario/thumbnail/mbiliario.jpg

the path: /localhost/villalba2/up/ is where is the blueimp jquery upload core

2
  • can you post lines 15-17 ? from index.php Commented Nov 7, 2014 at 15:27
  • yes, , sorry , i just edited Commented Nov 7, 2014 at 15:30

3 Answers 3

1

You must use quotes when you define a constant

define('DIR_DOWNLOAD', "/Applications/XAMPP/htdocs/villalba2");

Then the json output will be parsable

Sign up to request clarification or add additional context in comments.

1 Comment

Thank!!, now works, but the images are not displayed
1

In order to define constants they must be quoted in the definition -

define("DIR_DOWNLOAD", "/Applications/XAMPP/htdocs/villalba2");
define("HTTP_SERVER", "localhost/villalba2");

5 Comments

Thank!!, now works, but the images are not displayed
If the errors are gone then we can start looking at what is going on to prevent them from being displayed. You may want to edit your original post.
Are the images uploaded to the correct folder? If so the display issue may be another question because we have solved the error from this question @berti
Yes , the images are uploaded correctly, but in the browser aren't displayed. the URL is worng . I edit my post
NOW i solved. i edit define("HTTP_SERVER", "localhost/villalba2"); to define("HTTP_SERVER", "/villalba2");
-1

change

//error_reporting(E_ALL | E_STRICT);
error_reporting(E_STRICT);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.