/    Sign up×
Community /Pin to ProfileBookmark

Why my php uploaded file is not opening

Hi. this is my php code from the form sending called, index.php

[CODE]
<body>

<form method=”POST” action=”upload.php” enctype=”multipart/form-data”>

<h2>Upload your image here</h2>
<input type=”file” name=”img”/><br />
<input type=”submit” name=”upload” value=”Upload” />

</form>

</body>[/CODE]

and this is my uploded code on uploaded.php

[CODE]
<?php

$name = $_FILES[‘img’][‘name’];
$type = $_FILES[‘img’][‘type’];
$size = $_FILES[‘img’][‘size’];
$temp = $_FILES[‘img’][‘tmp_name’];
$error = $_FILES[‘img’][‘error’];

if($error > 0)
{
die(‘File did not upload’ . $error);
}

else
{
move_uploaded_file($temp, ‘uploaded/’ . $name);
echo “Image uploaded successfully”;
}
?>
[/CODE]

[B]Question:[/B]

The problem is that when the image is successfully uploaded so it appears in the uploaded folder with valid file name, size and type but when i click on it so it does not show the image, rather the image is being appeared with an error message that:

[QUOTE]

Windows Photo viewer can’t open this picture, because you don’t have the correct permissions to access the file location

[/QUOTE]

Not only with images, i also uploaded a video and it has also valid name, size and type but it can’t be played. VLC player gives error.

[B]Note:[/B]
I’m using Appserv instead of xamp or wamp etc.

Please guide me that is there anything wrong in my code?

to post a comment
PHP

7 Comments(s)

Copy linkTweet thisAlerts:
@rootFeb 14.2015 — Suggest you look in the sticky post at the top of this PHP forum, in it you will see how to do it.
Copy linkTweet thisAlerts:
@AdqusitauthorFeb 16.2015 — @127.0.0.1

There in the sticky post, i don't get my answer, because its just image insertion process, shown there. That's not what i need right now.

When i upload image into my folder (code is mentioned above) so the picture appears in the folder but it's not opening. Guide me for this.
Copy linkTweet thisAlerts:
@r8rFeb 16.2015 — Just poking in the dark, but your web user probably created a file with permissions that don't allow your windows user to access it. Go check the file properties in windows explorer and see who owns the file an who's allowed to do what.
Copy linkTweet thisAlerts:
@AdqusitauthorFeb 17.2015 — For the time being i am uploading picture from my PC.

How to check properties that who owns this file and who is allowed to do changes?
Copy linkTweet thisAlerts:
@ozoecJul 23.2017 — &#1587;&#1604;&#1575;&#1605;

&#1605;&#1606; &#1607;&#1605; &#1576;&#1607; &#1575;&#1740;&#1606; &#1605;&#1588;&#1705;&#1604; &#1576;&#1585;&#1582;&#1608;&#1585;&#1583; &#1705;&#1585;&#1583;&#1605;

&#1588;&#1605;&#1575; &#1580;&#1608;&#1575;&#1576;&#1740; &#1662;&#1740;&#1583;&#1575; &#1606;&#1705;&#1585;&#1583;&#1740;&#1583;&#1567;

Hello

I also encountered this problem

Did you find an answer?
Copy linkTweet thisAlerts:
@ginerjmJul 23.2017 — When the user views the image where is it - on the server? And the user is on a pc? How is your viewing software supposed to access it?
Copy linkTweet thisAlerts:
@Zora001Aug 14.2017 — I have no idea .?
×

Success!

Help @Adqusit spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.8,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...