Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
php Form including image upload
Old 07-14-2006, 05:19 PM php Form including image upload
Average Talker

Posts: 17
Name: D M
Trades: 0
Hi,
I need a form that is capable of uploading an image file. I'm sure this is simple enough; does anyone know where I can get such a script (and not hosted remotely)?

Thanks alot for any help.
__________________

Please login or register to view this content. Registration is FREE
WebFuel is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-16-2006, 05:23 AM Re: php Form including image upload
DavetheSniper's Avatar
Junior Talker

Posts: 2
Name: David
Trades: 0
try this:

<?
//set these variables-----------------------------------------------------------------
$path = "/images/"; //path to your targetfolder after your domain
$max_size = 500000; //maximum filesize
//optionally
$domain = $_SERVER["HTTP_HOST"]; //your domainname - change if necessary like "www.yourdomain.com"
//------------------------------------------------------------------------------------
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>file upload</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFCC" text="#990000" link="#990000" vlink="#990000" alink="#990000" leftmargin="20" topmargin="20" marginwidth="20" marginheight="20">
<FORM ENCTYPE="multipart/form-data" ACTION="index.php" METHOD="POST">
<strong><font color="#990000" face="Geneva, Arial, Helvetica, sans-serif">IMAGE (jpg/gif) </font></strong><font color="#990000">:</font>
<INPUT TYPE="file" NAME="userfile">
<INPUT TYPE="submit" VALUE="Upload">
</FORM>
<br>
<?
if (!isset($HTTP_POST_FILES['userfile'])) exit;
if (is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'])) {
if ($HTTP_POST_FILES['userfile']['size']>$max_size) {
echo "<font color=\"#333333\" face=\"Geneva, Arial, Helvetica, sans-serif\">File is too big !</font><br>\n"; exit; }
if (($HTTP_POST_FILES['userfile']['type']=="image/gif") || ($HTTP_POST_FILES['userfile']['type']=="image/pjpeg") || ($HTTP_POST_FILES['userfile']['type']=="image/jpeg") || ($HTTP_POST_FILES['userfile']['type']=="image/png")) {
if (file_exists("../".$path . $HTTP_POST_FILES['userfile']['name'])) {
echo "<font color=\"#333333\" face=\"Geneva, Arial, Helvetica, sans-serif\">There already exists a file with this name, please rename your file and try again</font><br>\n"; exit; }
$res = copy($HTTP_POST_FILES['userfile']['tmp_name'], "../".$path .$HTTP_POST_FILES['userfile']['name']);
if (!$res) { echo "<font color=\"#333333\" face=\"Geneva, Arial, Helvetica, sans-serif\">Didn't work, please try again</font><br>\n"; exit; } else {
?>
<br>
<p>
<font color="#333333" face="Geneva, Arial, Helvetica, sans-serif">Find your file here: <strong><font color="#990000"><a href="http://<? echo $domain; ?>/<? echo "../".$path; ?><? echo $HTTP_POST_FILES['userfile']['name']; ?>" target="_blank"><br>
http://<? echo $domain; ?>/<? echo $path; ?><? echo $HTTP_POST_FILES['userfile']['name']; ?><br>
</a></font></strong><br>
HTML:<br>
<font color="#990000"><strong>&lt;img src=&quot;http://<? echo $domain; ?>/<? echo $path; ?><? echo $HTTP_POST_FILES['userfile']['name']; ?>&quot;&gt;</strong></font><br>
<br>
BBCode: <font color="#990000"><strong><br>
</strong></font></font></p>
<?
}
echo "<font color=\"#333333\" face=\"Geneva, Arial, Helvetica, sans-serif\"><hr>";
echo "Name: ".$HTTP_POST_FILES['userfile']['name']."<br>\n";
echo "Size: ".$HTTP_POST_FILES['userfile']['size']." bytes<br>\n";
echo "Type: ".$HTTP_POST_FILES['userfile']['type']."<br>\n";
echo "</font>";
echo "<br><br><img src=\"http://".$domain."/".$path.$HTTP_POST_FILES['userfile']['name']."\">";
} else { echo "<font color=\"#333333\" face=\"Geneva, Arial, Helvetica, sans-serif\">Verkeerd bestandstype, enkel gif, jpg of png !!!</font><br>\n"; exit; }
}
?>

</body>
</html>

you will need to change the top vars.

hope this helps

Sniper
DavetheSniper is offline
Reply With Quote
View Public Profile
 
Old 07-16-2006, 05:44 AM Re: php Form including image upload
Junior Talker

Posts: 3
Name: gunluktr.com
Trades: 0
thank you friends

sorry I m letter speaking(write(ing) English because I m Turkish people's
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
gunluktr.com is offline
Reply With Quote
View Public Profile Visit gunluktr.com's homepage!
 
Old 07-17-2006, 12:21 AM Re: php Form including image upload
Junior Talker

Posts: 1
Name: Thai Hoang
Trades: 0
There are plenty of this kind of scripts on hotscripts.com, browse it you will find many useful open source.
Good luck
__________________

Please login or register to view this content. Registration is FREE
- Global solution for your online presence
jolielove is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to php Form including image upload
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.29296 seconds with 12 queries