When I Use Nginx Proxy, Image upload didn't work, Where can the problem occur?
Hi @MikeMaldini ,
Can you provide more detail like your Nginx settings, laravel version, error message or any other information?
@albertcht Yes i find some problem, when i didn't use proxy, i upload file it will upload in /public/storage/.. ( because its laravel's php artisan storage:link ) , But when i use proxy its will upload to /storage/ folder, it should be /storage/app/public/... , that's what i found, can you tell me how to fix this folder problem?
Hi @MikeMaldini ,
Do you mean your uploading works properly using this package but without Nginx proxy? If yes, I think you still need to provide your Nginx settings.
@albertcht That's my nginx config
# Default server configuration
#
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
server_tokens off; # Hidden Server Version
add_header X-Xss-Protection "1; mode=block"; # XSS Protect Header
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; # HSTS Header
root /var/www/Personal.Blog/public;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
server_name mikeblog.site;
location = /index.php {
# Ensure that there is no such file named "not_exists"
# in your "public" directory.
try_files /not_exists @swoole;
}
location / {
try_files $uri $uri/ @swoole;
}
location @swoole {
set $suffix "";
if ($uri = /index.php) {
set $suffix "/";
}
proxy_set_header Host $host;
proxy_set_header SERVER_PORT $server_port;
proxy_set_header REMOTE_ADDR $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
# IF https
proxy_set_header HTTPS "on";
proxy_temp_file_write_size 1000k;
proxy_pass http://127.0.0.1:1215$suffix;
}
}
Hi @MikeMaldini ,
I test my upload feature with the same Nginx config, and the file goes to correct location app/storage/....
Probably nothing to do with Nginx config, can you provide partial code about your upload logic?
@albertcht Yes, its my code, i use Intervention/image image package
...
$Str_Path_High = strtolower('STORAGE') . '/' . 'Original' . '/';
$Arr_Path['High'] = $Str_Path_High . $Str_Encrypt_FileName;
if( is_dir( $Str_Path_High ) == false ) mkdir( $Str_Path_High );
$Obj_Image_High = Image::make( $StrObj_File ) ->save( $Arr_Path['High'] );
...
Check out https://laravel.com/docs/5.6/requests#storing-uploaded-files and https://laravel.com/docs/5.6/filesystem . Use of Laravel's filesystem is encouraged over your own (kinda messy...) implementation.
Hi @MikeMaldini ,
Sorry for having difficulty finding any clues out from your code. Maybe you can try to dump the value of $Arr_Path['High']?
@emielmolenaar Thanks
@albertcht Ye,i find some solution, anyway thanks due
Most helpful comment
Check out https://laravel.com/docs/5.6/requests#storing-uploaded-files and https://laravel.com/docs/5.6/filesystem . Use of Laravel's filesystem is encouraged over your own (kinda messy...) implementation.