Fatal error: Namespace declaration statement has to be the very first statement in the script in

user2536244 picture user2536244 · Jan 29, 2014 · Viewed 146k times · Source

I'm trying to use this to create a image form upload for my website, the reason I'm using this is because it's more secure than doing everything myself (but if someone could point another working script I would be appreciated)

simon-eQ / ImageUploader

Fatal error: Namespace declaration statement has to be the very first statement in the script in C:\xampp\htdocs\project\lib\ImageUploader.php on line 4

Looking at the source code:

<br />
<b>Fatal error</b>:  Namespace declaration statement has to be the very first statement in the script in <b>C:\xampp\htdocs\project\lib\ImageUploader.php</b> on line <b>4</b><br />

I've tried with includes, requires and it still doesn't work.

Answer

Vivek Chaudhari picture Vivek Chaudhari · Jul 6, 2016

Sometimes this issue come because of space in PHP start tag of controller facing same issue just removed whitespace in:

<?php 
namespace App\Http\Controllers\Auth;

removing the space resolved my error