/    Sign up×
Community /Pin to ProfileBookmark

Image uploader.

Take a look at this code:

[CODE]<?
if (file_exists(“NOTE1)) {

echo “Sorry, that filename is taken. Please save it as another name and try again.”;

}
else
{

if(isset( $Submit ))
{
//If the Submitbutton was pressed do:

if ($_FILES[‘imagefile’][‘type’] == “image/gif”){

copy ($_FILES[‘imagefile’][‘tmp_name’], “files/”.$_FILES[‘imagefile’][‘name’])
or die (“Could not copy”);

echo “”;
echo “<br><b>Link for forums: </b>/files/”.$_FILES[‘imagefile’][‘name’].””;
echo “<br>Size: “.$_FILES[‘imagefile’][‘size’].””;
echo “Type: “.$_FILES[‘imagefile’][‘type’].””;

}

else {
echo “<br><br>”;
echo “Could Not Copy, Wrong Filetype (“.$_FILES[‘imagefile’][‘name’].”)<br>”;
}
}

}

?> [/CODE]

I have some things to ask people to change for me. line 2 If an image exists with the same filename i want the upload image to be given a random name. Can someone do this for me? Also how can i make it so i specify what filetypes can be uploaded, now it is if image/gif.

One last thing, in this part of the code:

[CODE]
echo “<br><b>Link for forums: </b>example.com/files/”.$_FILES[‘imagefile’][‘name’].””;
[/CODE]

I want to put that so the url of the image is in a textbox, however it gives an error even if i use “

For example

[CODE]
echo “<br><b>Link for forums: </b><input type=”text” value=”example.com/files/”.$_FILES[‘imagefile’][‘name’]”>.””;
[/CODE]

I would have thought that the above would be right.

One last thing. How can i add an image over the btm right corner of the image when its uploaded.

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@bathurst_guyMar 23.2007 — echo "&lt;br&gt;&lt;b&gt;Link for forums: &lt;/b&gt;&lt;input type="text" value="example.com/files/".$_FILES['imagefile']['name'].""&gt;";
×

Success!

Help @Tabo 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.25,
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,
)...