/    Sign up×
Community /Pin to ProfileBookmark

image upload

i need a script that enables someone to upload an image to my server ive looked all over and cannot find one that works can anyone refer me to one?

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYNov 14.2004 — From http://www.php.net/manual/en/features.file-upload.php

i think its what u mean, isnt it?or is it a full uploading code? there are plenty of those on the net.


[B]

therhinoman at hotmail dot com

27-Aug-2004 04:20

If your upload script is meant only for uploading images, you can use the image function getimagesize() (does not require the GD image library) to make sure you're really getting an image and also filter image types.

[code=php]
<?php getimagesize($file); ?>

...will return false if the file is not an image or is not accessable, otherwise it will return an array...

<?php
$file = 'somefile.jpg';

# assuming you've already taken some other
# preventive measures such as checking file
# extensions...

$result_array = getimagesize($file);

if ($result_array !== false) {
$mime_type = $result_array['mime'];
switch($mime_type) {
case "image/jpeg":
echo "file is jpeg type";
break;
case "image/gif":
echo "file is gif type";
break;
default:
echo "file is an image, but not of gif or jpeg type";
}
} else {
echo "file is not a valid image file";
}
?>[/code]


using this function along with others mentioned on this page, image ploading can be made pretty much fool-proof.

See http://php.net/manual/en/function.getimagesize.php for supported image types and more info.

[/B]
[/QUOTE]
Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYNov 14.2004 — first check this, its all explained : http://www.phpexamples.net/tutorial-10-1.html
×

Success!

Help @davey 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.15,
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,
)...