Page 1 of 1

Problem with Uploading Files

Posted: Mon Nov 24, 2003 8:26 am
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.

Posted: Mon Nov 24, 2003 8:42 am
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

Posted: Mon Nov 24, 2003 9:10 am
by tdelobe
aahhh. thanks, that did the trick!