I am using PHP to upload a file. The upload seems to be successful. The $_FILES array is:
Array ( [image] => Array ( [name] => mount.jpg [type] => image/jpeg [tmp_name] => /tmp/php61qYZj [error] => 0 [size] => 28947 ) )
Everything seems to be in order. However, when I do
echo '<img src="' . $_FILES['image']['tmp_name'] . '" />';
it gives me a broken image.
This is so basic, how can it possibly be failing?
$_FILES['image']['tmp_name']is a temporary storage and works for only one request. It is not available from web as long as it usually located at OS directory for temporary files/tmp. You need to move the file to some permanent storage which is available form web.