Jump to content
sEnte

Aviso com file_get_contents()

Recommended Posts

sEnte

Estou aqui a tentar criar uma maneira de se fazer o upload de uma imagem para o imgur.

<?php 
	
	if (isset($_POST['uploadprofileimg'])) {
		$image = base64_encode(file_get_contents($_FILES['profileimg']['tmp_name']));

		$options = array('http' => array(
			'method' => "POST",
            'header' => "Authorization: Bearer sdf1gs8fd1g8s3d8f3sgdf8s8fsdf1g3s8dfs8df\n",
			"Content-Type: application/x-www-form-urlencoded",
			'content' => $image
		));

		$context = stream_context_create($options);
		
		$imgurURL = "https://api.imgur.com/3/image";

		$response = file_get_contents($imgurURL, FALSE, $context);
	}
?>

<h1>My account</h1>
<form action="" method="post" enctype="multipart/form-data">
	Upload a profile image:
	<input type="file" name="profileimg">
	<input type="submit" name="uploadprofileimg" value="Upload Image">
</form>

O código faz o upload, no entanto, dá-me esta mensagem

Notice: file_get_contents(): Content-type not specified assuming application/x-www-form-urlencoded in C:\WebServer\Apache24\Apache24\htdocs\html\www\SocialNetwork\my-account.php on line 17

Não estou a perceber o porquê de estar a aparecer este erro


"If It Ain't Broke, Break it and build something Cooler!" Unknown

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.