NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page PHP Help

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 12-24-2005, 08:15 PM THREAD STARTER               #1 (permalink)
NamePros Member
Join Date: Dec 2005
Posts: 186
chronic will become famous soon enoughchronic will become famous soon enough
 



PHP Help


I need help making this script work. For some reason, it won't let me upload the files. I took this script from a thread on here and modified it but it still doesn't work. Any ideas? The error says it is on line 25 and I have no clue what might be wrong there.

PHP Code:
<?php
if($_POST[finshed] == '1') {
$upload_dir "images/";
$max_size 1024000;

if(
is_uploaded_file($_FILES['image']['tmp_name']))
{
  
$size $_FILES['image']['size'];

  if(
$size $max_size)
  {
    echo 
"File Too Large. File must be no larger than <b>$max_size</b> bytes.";
    exit();
  }
  
$filename $_FILES['image']['name'];
????: NamePros.com http://www.namepros.com/programming/151060-php-help.html

  if(
file_exists($upload_dir.$filename))
  {
    echo 
"Error: The file named <b>$filename</b> already exists.";
    exit();
  }

  if(
move_uploaded_file($_FILES['image']['tmp_name'], $upload_dir.$filename))
  {
    echo 
"Your image uploaded successfully!<br />
    <input type=\"text\" onClick='highlight(this);' style=\"width: 500px\" size=\"70\" value=\"[URL=http://atyourhost.com][IMG]http://www.atyourhost.com/\".
$upload_dir.$filename.\"[/IMG][/URL]\" /> Forum Hotlink 1<br /><br />
<input type=\"text\" onClick='highlight(this);' style=\"width: 500px\" size=\"70\" value=\"[url=http://imageshack.us][img=http://www.atyourhost.com/\".
$upload_dir.$filename.\"][/url]\" /> Forum Hotlink 2<br /><br />
<input type=\"text\" onClick='highlight(this);' style=\"width: 500px\" size=\"70\" value=\"http://www.atyourhost.com/\".
$upload_dir.$filename.\"\" /> Direct Link<br /><br />"";
    exit();
  }
  else
  {
    echo "
There was a problem uploading your filePlease try again.";
    exit();
  }
}
}else{
?>
<html>
<head>
<title>Image upload</title>
</head>
<body>

<form action="
upload.php" method="post" enctype="multipart/form-data">
<input type="
hidden" name="finshed" value="1">
????: NamePros.com http://www.namepros.com/showthread.php?t=151060
Image: <input type="
file" name="image" size="20">&nbsp;
<input type="
submit" name="submit" value="Upload">
</form>
</body>
</html>
<?php } ?>
__________________
DNFind.net - For sale, PM me.
chronic is offline  
Old 12-24-2005, 08:41 PM   #2 (permalink)
Senior Member
 
Eric's Avatar
Join Date: Mar 2005
Posts: 4,948
Eric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatness
 

Member of the Month
MOTM September 2005
Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Animal Rescue Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Baby Health Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse Diabetes Protect Our Planet Multiple Sclerosis Autism Adoption Special Olympics
Try this:

PHP Code:
<?php
if($_POST[finshed] == '1') {
$upload_dir "images/";
$max_size 1024000;

if(
is_uploaded_file($_FILES['image']['tmp_name']))
{
  
$size $_FILES['image']['size'];

  if(
$size $max_size)
  {
    echo 
"File Too Large. File must be no larger than <b>$max_size</b> bytes.";
????: NamePros.com http://www.namepros.com/showthread.php?t=151060
    exit();
  }
  
$filename $_FILES['image']['name'];

  if(
file_exists($upload_dir.$filename))
  {
    echo 
"Error: The file named <b>$filename</b> already exists.";
    exit();
  }

  if(
move_uploaded_file($_FILES['image']['tmp_name'], $upload_dir.$filename))
????: NamePros.com http://www.namepros.com/showthread.php?t=151060
  {
    echo 
"Your image uploaded successfully!<br />
    <input type=\"text\" onClick='highlight(this);' style=\"width: 500px\" size=\"70\" value=\"[URL=http://atyourhost.com][IMG]http://www.atyourhost.com/"
.$upload_dir.$filename."[/IMG][/URL]\" /> Forum Hotlink 1<br /><br />
    <input type=\"text\" onClick='highlight(this);' style=\"width: 500px\" size=\"70\" value=\"[url=http://imageshack.us][img=http://www.atyourhost.com/"
.$upload_dir.$filename."][/url]\" /> Forum Hotlink 2<br /><br />
    <input type=\"text\" onClick='highlight(this);' style=\"width: 500px\" size=\"70\" value=\"http://www.atyourhost.com/"
.$upload_dir.$filename."\" /> Direct Link<br /><br />";
    exit();
  }
  else
  {
    echo 
"There was a problem uploading your file. Please try again.";
    exit();
  }
}
}else{
?>
<html>
<head>
<title>Image upload</title>
</head>
<body>

<form action="upload.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="finshed" value="1">
Image: <input type="file" name="image" size="20">&nbsp;
<input type="submit" name="submit" value="Upload">
</form>
</body>
</html>
<?php ?>
Eric is offline  
Old 12-24-2005, 09:16 PM THREAD STARTER               #3 (permalink)
NamePros Member
Join Date: Dec 2005
Posts: 186
chronic will become famous soon enoughchronic will become famous soon enough
 



Still doesn't work.

Code:
Warning: move_uploaded_file(uploaded/header.gif): failed to open stream: No such file or directory in /home/vergear/public_html/upload.php on line 25

Warning: move_uploaded_file(): Unable to move '/tmp/phpaKIz2c' to 'uploaded/header.gif' in /home/vergear/public_html/upload.php on line 25
There was a problem uploading your file. Please try again.
I will check back later to see if if anyone has some updates for me.
????: NamePros.com http://www.namepros.com/showthread.php?t=151060

If someone completely fixes it, I may give you a free domain name.
__________________
DNFind.net - For sale, PM me.
chronic is offline  
Old 12-24-2005, 09:26 PM   #4 (permalink)
Senior Member
 
Eric's Avatar
Join Date: Mar 2005
Posts: 4,948
Eric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatness
 

Member of the Month
MOTM September 2005
Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Animal Rescue Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Baby Health Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse Diabetes Protect Our Planet Multiple Sclerosis Autism Adoption Special Olympics
You sure you have the uploaded folder created, plus CHMOD'ed to 777?
Eric is offline  
Old 12-24-2005, 10:15 PM THREAD STARTER               #5 (permalink)
NamePros Member
Join Date: Dec 2005
Posts: 186
chronic will become famous soon enoughchronic will become famous soon enough
 



Yeah. I will double check it though.

Ah, it works now. But when I upload an image, it doesn't display it properly in the boxes.

http://atyourhost.com/upload.php < Try it yourself and look at the result
__________________
DNFind.net - For sale, PM me.
chronic is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tutorial: Getting started with PHP (The Basics) deadserious Webmaster Tutorials 60 11-17-2007 12:35 PM
Great Scripts for Sale With Resale Rights! Zeeble Scripts For Sale 20 01-04-2006 02:39 AM
Googlism - What does google think of you? deadserious The Break Room 55 12-15-2005 10:09 AM

Liquid Web Smart Servers  
All times are GMT -7. The time now is 05:54 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger