Page 1 of 1

uploading

Posted: Thu Jan 02, 2003 2:43 am
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.

Posted: Thu Jan 02, 2003 4:17 am
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?

Posted: Thu Jan 02, 2003 4:20 am
by cheatboy00
yes.. it uploads the selected file from the users hd to the server.

Posted: Thu Jan 02, 2003 4:26 am
by Super Webmaster

Posted: Thu Jan 02, 2003 4:28 am
by laserlight
Go to the php manual and look up the copy() function.

http://www.php.net/manual/en/function.copy.php

Posted: Fri Jan 03, 2003 1:19 am
by horgh

Posted: Fri Jan 03, 2003 9:21 am
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:

?>

Posted: Fri Jan 03, 2003 7:48 pm
by cheatboy00
thanks for all the help.

puREp3s+ duno how to fix your problem though... gl

Posted: Fri Jan 03, 2003 8:34 pm
by hob_goblin
you need to use the $_FILES array, read the links that were shown above.