Problem with Uploading Files

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
tdelobe
Forum Commoner
Posts: 41
Joined: Thu Aug 07, 2003 2:28 pm
Location: washington, dc

Problem with Uploading Files

Post by tdelobe »

I am having trouble using PHP to upload files via a webpage to a directory on my server. This is the error I continue to get...

Warning: copy(test.doc): failed to open stream: HTTP wrapper does not support writeable connections.

Is there a setting in php.ini I need to make in order for the copy() function to work properly, or is this the result of some server permission settings not allowing me to copy to that directory. I didn't think it was the latter seeing I could save files into that directory without a problem.

Here is my code:

Code: Select all

<?php

if ($File) &#123;
	print ("File Name: $file_name<br>");
	print ("File Size: $file_size<br>");

	if (copy ($File, "http://dev.usta.org/includes/$File_name")) &#123;
		print ("File was successfully uploaded.<br><br>");
		&#125; else &#123;
		print ("Sorry, file could not be uploaded.<br><br>");
		&#125;
	unlink ($File);
	
	&#125; else &#123;
	
	print ("<strong>Upload a file to the filings server:</strong>");
	print ("<FORM action="$PHP_Self" method="POST" ENCTYPE="multipart/form-data">");
	
	?>	
	File: <input type="FILE" name="File" size=20 class="forms"> <input type="submit" name="submit" value="submit" class="forms">
	</form><br>
	
	<? &#125; ?>
Any help would be greatly appreciated. Thanks.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

you need to use the full server path to the includes directory, not a http:// address.

You can have it as a URL, but something needs to be enabled, which allows these type of http connection.

read the manual - there is some notes on it http://se.php.net/manual/en/function.copy.php

Mark
tdelobe
Forum Commoner
Posts: 41
Joined: Thu Aug 07, 2003 2:28 pm
Location: washington, dc

Post by tdelobe »

aahhh. thanks, that did the trick!
Post Reply