1

I have website build on Symfony and I'm using TinyMCE (not as a bundle, but JS script in web folder). I have installed plugin jbimages from justboil.me for image upload. But when I try to upload an image I get error "The upload path does not appear to be valid". Even on localhost, even on domain.

I think it's because symfony's accessible files are not in root. But how to solve it?

My config for saving files:

$config['img_path'] = './images/upload'; // Relative to domain name
$config['upload_path'] = $_SERVER['DOCUMENT_ROOT'] . $config['img_path']; // Physical path. [Usually works fine like this]

Thanks and sorry for my english, I'm learning.

5 Answers5

1

Just remove the leading dot

$config['img_path'] = '/images/upload';

1

I know this is old. I had an application to design and came across this issue. The solution I implemented was simply to leave it blank.

$config['img_path'] = ''; // Relative to domain name

Like so and everything should be fine.

pimpace
  • 307
  • 3
  • 12
0

My solution - change first line of this code:

if (!empty($_POST['image-folder']) {
    $config['img_path'] = '/someFolder/' . $_POST['image-folder'];
}

to:

if (!empty($_POST['image-folder']) && $_POST['image-folder'] !== 'undefined') {
    $config['img_path'] = '/someFolder/' . $_POST['image-folder'];
}
suz
  • 737
  • 2
  • 9
  • 22
0

The solution is to give the path from the server root:

For example, I use XAMPP. I created a www folter in htdocs so i can manage all my projects easily.

Here is an example folder structure:

xampp --> htdocs --> www --> myproject --> images

so the path looks like this:

$config['img_path'] = '/www/myproject/images';

Works like charm for me, hope this will help you guys too :)

DRYN
  • 15
  • 1
  • 1
  • 6
0

$config['img_path'] = ''; // Relative to domain name $config['upload_path'] = $_SERVER['DOCUMENT_ROOT'] . $config['img_path'].'/public/image'; // Physical path. [Usually works fine like this] $config['img_path'] = '/public/image';

  • 1
    Welcome to SO. Well done for showing your code but try and make the question more specific, explain your desired outcome. Also, put 4 spaces before lines of code to format it as a code block. – Martin Joiner Sep 03 '17 at 18:18