NameSilo

PHP Help

Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
Namecheap AuctionsNamecheap Auctions
Watch

chronic

Established Member
Impact
1
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:
<?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'];

  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 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"> 
<input type="submit" name="submit" value="Upload">
</form>
</body>
</html>
<?php } ?>
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Try this:

PHP:
<?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'];

  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 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"> 
<input type="submit" name="submit" value="Upload">
</form>
</body>
</html>
<?php } ?>
 
0
Close
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.

If someone completely fixes it, I may give you a free domain name.
 
0
Close
You sure you have the uploaded folder created, plus CHMOD'ed to 777?
 
0
Close
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
 
0
Close
DomainEasy: white label portfolios are live. Enable yours.

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Switch between accounts
You can now stay logged in to more than one NamePros account in the same browser. Click your avatar, then "Accounts in this browser", to...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back