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

Undefined array key "tmp_name" - paste images #228

Closed
1 task
ffiesta opened this issue Jan 3, 2025 · 3 comments
Closed
1 task

Undefined array key "tmp_name" - paste images #228

ffiesta opened this issue Jan 3, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@ffiesta
Copy link
Contributor

ffiesta commented Jan 3, 2025

Describe your issue

When i paste a image from web directly on wiki page, wikidocs create error_log file with

[03-Jan-2025 12:07:16 UTC] PHP Warning:  Undefined array key "tmp_name" in /example.pt/submit.php on line 306

When use wikidocs image upload system work's fine!

Device and settings

WIndows 10 Pro, Chrome browser

Steps to reproduce

  1. Open/edit wikidocs page
  2. copy image from webpage
  3. paste on wikidocs page

Screenshots (optional)

No response

Extra fields

  • I'd like to work on this issue
@ffiesta ffiesta added the bug Something isn't working label Jan 3, 2025
@ffiesta
Copy link
Contributor Author

ffiesta commented Jan 3, 2025

After some analisys I change line 306,

from if($image['tmp_name']){ to if (isset($image['tmp_name']) && $image['tmp_name']) {

2nd line of code:

	// check for posted image
	if($image['tmp_name']){
		if(move_uploaded_file($image['tmp_name'],$DOC->DIR.$file_name)){$uploaded=true;}
		// check for pasted image
	}elseif(strlen($image['base64'])){
		$bytes=file_put_contents($DOC->DIR.$file_name,base64_decode($image['base64']));
		if($bytes>0){
			$image['size']=$bytes;
			$uploaded=true;
		}
	}

to

// check for posted image
	if(isset($image['tmp_name']) && $image['tmp_name']){
		if(move_uploaded_file($image['tmp_name'],$DOC->DIR.$file_name)){$uploaded=true;}
		// check for pasted image
	}elseif(strlen($image['base64'])){
		$bytes=file_put_contents($DOC->DIR.$file_name,base64_decode($image['base64']));
		if($bytes>0){
			$image['size']=$bytes;
			$uploaded=true;
		}
	}

I tested with paste and with wikidocs image upload and it work! Please verify.

@Zavy86
Copy link
Owner

Zavy86 commented Jan 7, 2025

@ffiesta can you create a pull requests?

@ffiesta
Copy link
Contributor Author

ffiesta commented Jan 7, 2025

@ffiesta can you create a pull requests?

DONE #231

@ffiesta ffiesta closed this as completed Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants