File upload from server failed
File upload from server failed
Hello,
I have a problem loading image files. In localhost it works perfectly, but not when uploading it to the server.
When trying to upload, I get an error “A server error occurred while uploading the file”
In the database, the writing of all the fields seems correct, except the field "system_path", which writes a rather strange path:
/var/www/vhost/javierlasen.es/home/html/uploads/1.jpg
When the correct path in the browser would be:
https;//www.javierlasen.es/mapas/uploads/1.jpg
and physically the image would have to be saved on the server in the path:
html/mapas/uploads/1.jpg
Thanks
Replies
That’s the file system path (equivalent of C:\ if you are a windows user).
That’s the web accessible path. You’ll need both paths throughout the lifetime of the file on the server.
It looks like you might just be missing the
mapas
part from your system path. Can you show me how you have configured the upload code please?Allan
Thanks Allan for answering,
The field corresponding to the image in the editor looks like this:
The data is collected from the database, in this way:
Indeed, adding "maps" works perfectly.
What I still do not understand is that it does not point to a type route: https: // www ...
Because www.whatever could be anywhere on your server.
The way the web-server you are using works is that it will define a webroot - in your case that will be
/var/www/vhost/javierlasen.es/home/html/
(and can be accessed in PHP as$_SERVER['DOCUMENT_ROOT']
).That means that any file under that system path can be accessed from the web. If something was at
/var/www/vhost/javierlasen.es/home/html/datatables.html
then you could usejavierlasen.es/datatables.html
for example.Generally with PHP URL paths will map directly to the system paths. You just need to know the web root to complete the mapping.
Hope that helps.
Allan
A lot.
Thank you very much for the help and the explication.