php - Froala Editor Image Upload Error
I have read the documentation of Froala editor. And tried to reproduce this example at my local server.
But, I cannot make it work. Code is the same as the documentation, but my folder structure is as follows:
cac/web/
uploads/
upload.php
I keep getting errors. No matter how I change the image path. I just don't understand too much how should I place the paths with my given folder structure.
<br />
<b>Warning</b>: move_uploaded_file(/cac/web/uploads/069fc534ceb01b2217e12b72583aff80005cb3e8.png): failed to open stream: No such file or directory in <b>/Applications/XAMPP/xamppfiles/htdocs/cac/web/upload.php</b> on line <b>24</b><br />
<br />
<b>Warning</b>: move_uploaded_file(): Unable to move '/Applications/XAMPP/xamppfiles/temp/phpQJYxaP' to '/cac/web/uploads/069fc534ceb01b2217e12b72583aff80005cb3e8.png' in <b>/Applications/XAMPP/xamppfiles/htdocs/cac/web/upload.php</b> on line <b>24</b><br />
{"link":"/uploads/069fc534ceb01b2217e12b72583aff80005cb3e8.png"}
Answer
Solution:
Changing line
move_uploaded_file($_FILES["file"]["tmp_name"], "/uploads/" . $name);
tomove_uploaded_file($_FILES["file"]["tmp_name"], getcwd() . "/uploads/" . $name);
should get it to work.