uploading

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
cheatboy00
Forum Contributor
Posts: 151
Joined: Sat Jun 29, 2002 10:36 am
Location: canada
Contact:

uploading

Post by cheatboy00 »

I got no idea how to even start to do this so here goes.

I'm creating an online database of files and such, and I want other people to beable to use an upload files form to get the files online.

so you come login, goto contribute, then click a browse button and your c:\ opens up in it and then can select a file to put on the site.

if you understand what I'm trying to say, please help.
Super Webmaster
Forum Newbie
Posts: 2
Joined: Thu Jan 02, 2003 4:17 am
Location: Rotterdam, The Netherlands

Post by Super Webmaster »

I not so sure if I understand that ...
Do you mean script that uploads a file from the HD to a server?
User avatar
cheatboy00
Forum Contributor
Posts: 151
Joined: Sat Jun 29, 2002 10:36 am
Location: canada
Contact:

Post by cheatboy00 »

yes.. it uploads the selected file from the users hd to the server.
Super Webmaster
Forum Newbie
Posts: 2
Joined: Thu Jan 02, 2003 4:17 am
Location: Rotterdam, The Netherlands

Post by Super Webmaster »

laserlight
Forum Commoner
Posts: 28
Joined: Wed Jan 01, 2003 6:41 am

Post by laserlight »

Go to the php manual and look up the copy() function.

http://www.php.net/manual/en/function.copy.php
User avatar
horgh
Forum Newbie
Posts: 23
Joined: Mon Oct 21, 2002 9:50 am
Location: GER
Contact:

Post by horgh »

puREp3s+
Forum Newbie
Posts: 7
Joined: Tue Dec 17, 2002 1:53 am
Location: Scotland

Post by puREp3s+ »

I have tried to use the copy function. Here is the code that I used:

Code: Select all

<?php 
	if ($file == "none")
	{ 
		print "You must specify a file to upload"; 
	} 
	else
	{ 
		copy($file, "/httpdocs/images"); 
		unlink($file); 
	} 
?>
I am getting an error saying

Warning: open_basedir restriction in effect. File is in wrong directory in /usr/local/psa/home/vhosts/xbox-dimension.co.uk/httpdocs/upload/upload.php on line 8

I also tried to use move_uploaded_file() instead of copy() and I got

Warning: Unable to create '/upload/fan1.jpg': No such file or directory in /usr/local/psa/home/vhosts/xbox-dimension.co.uk/httpdocs/upload/upload2.php on line 30

Warning: Unable to move '/tmp/phpyaEF2i' to '/upload/fan1.jpg' in /usr/local/psa/home/vhosts/xbox-dimension.co.uk/httpdocs/upload/upload2.php on line 30

as an error message.

Can anyone please help me :evil:

?>
User avatar
cheatboy00
Forum Contributor
Posts: 151
Joined: Sat Jun 29, 2002 10:36 am
Location: canada
Contact:

Post by cheatboy00 »

thanks for all the help.

puREp3s+ duno how to fix your problem though... gl
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

you need to use the $_FILES array, read the links that were shown above.
Post Reply