Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload file failed #32

Closed
MikeMaldini opened this issue May 5, 2018 · 10 comments
Closed

Upload file failed #32

MikeMaldini opened this issue May 5, 2018 · 10 comments

Comments

@MikeMaldini
Copy link

When I Use Nginx Proxy, Image upload didn't work, Where can the problem occur?

@albertcht
Copy link
Member

Hi @MikeMaldini ,

Can you provide more detail like your Nginx settings, laravel version, error message or any other information?

@MikeMaldini
Copy link
Author

@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?

@albertcht
Copy link
Member

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.

@MikeMaldini
Copy link
Author

MikeMaldini commented May 6, 2018

@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;
    }
}

@albertcht
Copy link
Member

albertcht commented May 6, 2018

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?

@MikeMaldini
Copy link
Author

@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'] );
...

@emielmolenaar
Copy link

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.

@albertcht
Copy link
Member

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']?

@MikeMaldini
Copy link
Author

@emielmolenaar Thanks

@MikeMaldini
Copy link
Author

@albertcht Ye,i find some solution, anyway thanks due

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants