Failed to open stream? Image upload but are not echoing

Rebecca Joanna

I am working on upload file in php. i done it successfully but when i want to print it it give me error plz help me My php Script is below

<?php
$target_dir = "C:\wamp\www\upload\upload/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);

if(isset($_POST["submit"])) {
    $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
    if($check !== false) {
        echo "File is an image - " . $check["mime"] . ".";
        $uploadOk = 1;
    } else {
        echo "File is not an image.";
        $uploadOk = 0;
    }
}

if (file_exists($target_file)) {
    echo "Sorry, file already exists.";
    $uploadOk = 0;
}

if ($_FILES["fileToUpload"]["size"] > 500000) {
    echo "Sorry, your file is too large.";
    $uploadOk = 0;
}

if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
&& $imageFileType != "gif" ) {
    echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
    $uploadOk = 0;
}

if ($uploadOk == 0) {
    echo "Sorry, your file was not uploaded.";

} else {
    if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
        echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
    } else {
        echo "Sorry, there was an error uploading your file.";
    }
	
	if(copy($_FILES['fileToUpload']['name'], $target_dir))
{
echo "Successful<BR/>";
echo "File Name :".$_FILES['fileToUpload']['name']."<BR/>";
echo "File Size :".$_FILES['fileToUpload']['size']."<BR/>";
echo "File Type :".$_FILES['fileToUpload']['type']."<BR/>";
echo "<img src=\"$target_dir\" width=\"150\" height=\"150\">";
}
}
?>

following error occur

enter image description here

it should be print like this once it uploaded enter link description here

Masroor_Shah

TRy like this

	if (is_file($target_file))
{
echo "Successful<BR/>";
echo "File Name :".$_FILES['fileToUpload']['name']."<BR/>";
echo "File Size :".$_FILES['fileToUpload']['size']."<BR/>";
echo "File Type :".$_FILES['fileToUpload']['type']."<BR/>";
echo "<img src=\"$target_file\" width=\"150\" height=\"150\">";
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Failed to open stream when uploading image to server

From Dev

PHP - failed to open stream error for uploaded image

From Dev

Failed to open stream when uploading image to server

From Dev

File upload on s3 : failed to open stream: No such file or directory

From Dev

Move_upload_file() is failed to open stream and Unable to move file

From Dev

PHP-File upload failed to open stream - wrong folder

From Dev

open failed: EACCES (Permission denied) in marshmallow while upload image to server

From Dev

Failed to open stream when uploa image in php // using Mysql

From Dev

failed to open stream - XAMPP

From Dev

failed to open stream

From Dev

failed to open stream

From Dev

Failed to upload an image

From Dev

failed upload image to database

From Dev

Laravel S3 file upload : fopen(path to file) failed to open stream: Permission denied

From Dev

php file upload error warning move_uploaded_file failed to open stream permission denied in

From Dev

Warning: move_uploaded_file(upload/200.jpg): failed to open stream

From Dev

Laravel setup failed to open stream

From Dev

failed to open stream on magento module

From Dev

ZipArchive: `failed to open stream: Is a directory`

From Dev

Zend/Loader failed to open stream

From Dev

ZipArchive: `failed to open stream: Is a directory`

From Dev

Failed to open stream: No such file or directory

From Dev

failed to open stream: No such file or directory

From Dev

PHP error failed to open stream/failed opening

From Dev

PHP error failed to open stream/failed opening

From Dev

simple html dom failed to open stream for a site

From Dev

Something.php failed to open stream - yii

From Dev

Blank page due to error "failed to open stream"

From Java

PHP - Failed to open stream : No such file or directory

Related Related

  1. 1

    Failed to open stream when uploading image to server

  2. 2

    PHP - failed to open stream error for uploaded image

  3. 3

    Failed to open stream when uploading image to server

  4. 4

    File upload on s3 : failed to open stream: No such file or directory

  5. 5

    Move_upload_file() is failed to open stream and Unable to move file

  6. 6

    PHP-File upload failed to open stream - wrong folder

  7. 7

    open failed: EACCES (Permission denied) in marshmallow while upload image to server

  8. 8

    Failed to open stream when uploa image in php // using Mysql

  9. 9

    failed to open stream - XAMPP

  10. 10

    failed to open stream

  11. 11

    failed to open stream

  12. 12

    Failed to upload an image

  13. 13

    failed upload image to database

  14. 14

    Laravel S3 file upload : fopen(path to file) failed to open stream: Permission denied

  15. 15

    php file upload error warning move_uploaded_file failed to open stream permission denied in

  16. 16

    Warning: move_uploaded_file(upload/200.jpg): failed to open stream

  17. 17

    Laravel setup failed to open stream

  18. 18

    failed to open stream on magento module

  19. 19

    ZipArchive: `failed to open stream: Is a directory`

  20. 20

    Zend/Loader failed to open stream

  21. 21

    ZipArchive: `failed to open stream: Is a directory`

  22. 22

    Failed to open stream: No such file or directory

  23. 23

    failed to open stream: No such file or directory

  24. 24

    PHP error failed to open stream/failed opening

  25. 25

    PHP error failed to open stream/failed opening

  26. 26

    simple html dom failed to open stream for a site

  27. 27

    Something.php failed to open stream - yii

  28. 28

    Blank page due to error "failed to open stream"

  29. 29

    PHP - Failed to open stream : No such file or directory

HotTag

Archive