AZForums: PHP file uploader - AZForums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

PHP file uploader <?php>

#1 User is offline   Oosband Icon

  • DnB Oos
  • PipPipPipPipPipPipPipPipPipPip
  • View blog
Group:
+ Legendary
Posts:
5,527
Joined:
30-August 05
Location:
UK

Posted 09 April 2006 - 05:05 PM

Want to make a simple PHP file uploader for your site?
Here it is!

<?php

$action = $_POST["action"];
$max_size = "10485760"; // Max size in BYTES (Currently 10MB)

echo "
<html>
<center>
<form action='upload.php' method=post  enctype='multipart/form-data'>
Select A File To Upload:<br>

<input type='file' name='filename'><p>
<input type='reset' value='Reset'>
<input type='hidden' name='action' value='upload'>
<input type='submit' value='Upload File'>
</form>";


if ($action == 'upload')
{
	
	
	if ($_FILES["filename"]["size"] > $max_size) die ("<b>File too big!  Try again...</b>");
	
	
	copy($_FILES["filename"]["tmp_name"],"./".$_FILES["filename"]["name"]) or die("<b><font color='red'>Unknown error! Please e-mail me if the problem persists.</b></font>");
	echo "<b><font color='green'>File Uploaded. <a href='../uploads/' target='_blank'>Click here</a> to see your file(s).</b></font>"; // for debug -->  $filename --> ".$destination."/".$filename_name."</h2>";
	
	
}
	
?>


The variables at the beginning set the Action to post the picture into the supplied folder uploads.
Hence we need to create a folder in the main directory with CHMOD 777 [all permissions] to enable the files to be uploaded.
The form is basic input fields.
Files that are larger than the allocated amount will not be uploaded.
0

#2 User is offline   gameguider Icon

  • The Missing Link
  • PipPipPipPipPipPipPipPipPipPipPip
  • View blog
Group:
Disabled Account
Posts:
10,741
Joined:
19-April 06

Posted 02 May 2006 - 04:48 PM

I have done all that, but when I press upload file, it comes up with the error page from my web host.

:(
Posted Image

#3 User is offline   Oosband Icon

  • DnB Oos
  • PipPipPipPipPipPipPipPipPipPip
  • View blog
Group:
+ Legendary
Posts:
5,527
Joined:
30-August 05
Location:
UK

Posted 02 May 2006 - 05:03 PM

Who's your web host?
Also, can you please print the error here?
0

#4 User is offline   gameguider Icon

  • The Missing Link
  • PipPipPipPipPipPipPipPipPipPipPip
  • View blog
Group:
Disabled Account
Posts:
10,741
Joined:
19-April 06

Posted 02 May 2006 - 05:21 PM

Web host= awardspace.com

Then it redirects to this page: http://www.awardspac..._by_google.html
Posted Image

#5 User is offline   Oosband Icon

  • DnB Oos
  • PipPipPipPipPipPipPipPipPipPip
  • View blog
Group:
+ Legendary
Posts:
5,527
Joined:
30-August 05
Location:
UK

Posted 02 May 2006 - 05:28 PM

Does your host allow CHMOD?
0

#6 User is offline   gameguider Icon

  • The Missing Link
  • PipPipPipPipPipPipPipPipPipPipPip
  • View blog
Group:
Disabled Account
Posts:
10,741
Joined:
19-April 06

Posted 02 May 2006 - 05:30 PM

yep, I checked all of the check boxes
Posted Image

#7 User is offline   Oosband Icon

  • DnB Oos
  • PipPipPipPipPipPipPipPipPipPip
  • View blog
Group:
+ Legendary
Posts:
5,527
Joined:
30-August 05
Location:
UK

Posted 03 May 2006 - 08:00 PM

OK then, do you have an online version I can look at?
This worked fine on my test server.
0

#8 User is offline   gameguider Icon

  • The Missing Link
  • PipPipPipPipPipPipPipPipPipPipPip
  • View blog
Group:
Disabled Account
Posts:
10,741
Joined:
19-April 06

Posted 04 May 2006 - 05:52 PM

http://gameguider.aw...com/upload.html
Posted Image

#9 User is offline   Oosband Icon

  • DnB Oos
  • PipPipPipPipPipPipPipPipPipPip
  • View blog
Group:
+ Legendary
Posts:
5,527
Joined:
30-August 05
Location:
UK

Posted 04 May 2006 - 06:56 PM

View Postgameguider, on May 4 2006, 06:52 PM, said:



It doesn't even load for me...
But, if it's .html please rename to .php.
0

#10 User is offline   gameguider Icon

  • The Missing Link
  • PipPipPipPipPipPipPipPipPipPipPip
  • View blog
Group:
Disabled Account
Posts:
10,741
Joined:
19-April 06

Posted 05 May 2006 - 03:39 PM

I changed it, and it works, but when I click on the bit to show me the file, it just takes me here: http://www.awardspac..._by_google.html
Posted Image

#11 User is offline   Oosband Icon

  • DnB Oos
  • PipPipPipPipPipPipPipPipPipPip
  • View blog
Group:
+ Legendary
Posts:
5,527
Joined:
30-August 05
Location:
UK

Posted 05 May 2006 - 09:10 PM

Right, the script is linking to a whole folder, /uploads/ - it appears that is not present on your space, what did you call the folder?
0

#12 User is offline   gameguider Icon

  • The Missing Link
  • PipPipPipPipPipPipPipPipPipPipPip
  • View blog
Group:
Disabled Account
Posts:
10,741
Joined:
19-April 06

Posted 06 May 2006 - 08:01 AM

I called it uploads
Posted Image

#13 User is offline   Oosband Icon

  • DnB Oos
  • PipPipPipPipPipPipPipPipPipPip
  • View blog
Group:
+ Legendary
Posts:
5,527
Joined:
30-August 05
Location:
UK

Posted 07 May 2006 - 07:02 PM

Very weird...
It works perfectly on my space, I'll see what I can do for you hosting-wise...
0

#14 User is offline   gameguider Icon

  • The Missing Link
  • PipPipPipPipPipPipPipPipPipPipPip
  • View blog
Group:
Disabled Account
Posts:
10,741
Joined:
19-April 06

Posted 08 May 2006 - 09:17 AM

Thanks:)
Posted Image

#15 User is offline   gameguider Icon

  • The Missing Link
  • PipPipPipPipPipPipPipPipPipPipPip
  • View blog
Group:
Disabled Account
Posts:
10,741
Joined:
19-April 06

Posted 16 May 2006 - 06:58 AM

Any updates?
Posted Image

#16 User is offline   Oosband Icon

  • DnB Oos
  • PipPipPipPipPipPipPipPipPipPip
  • View blog
Group:
+ Legendary
Posts:
5,527
Joined:
30-August 05
Location:
UK

Posted 16 May 2006 - 09:24 AM

All my servers are still offline, so I'll begin to find you a cool free host.
0

#17 User is offline   gameguider Icon

  • The Missing Link
  • PipPipPipPipPipPipPipPipPipPipPip
  • View blog
Group:
Disabled Account
Posts:
10,741
Joined:
19-April 06

Posted 16 May 2006 - 02:57 PM

:)
Posted Image

#18 User is offline   Webhog.be Icon

  • AZ Recruit
  • PipPipPip
  • View blog
Group:
Members
Posts:
31
Joined:
24-May 06

Posted 31 May 2006 - 11:44 PM

Wauw man, that's a nice script..
I will try this out :D

Could be useful :P
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users