Jump to content

File Upload Problem


Perad

Recommended Posts

I have changed getcwd(); to get_option('port_url') in an attempt to make this a little more dynamic. However I am now getting errors.

 

Could someone help to tell me what is going wrong.

 

Error:

Warning: move_uploaded_file(http://localhost/wordpress/portfolio/Photo1.jpg) [function.move-uploaded-file]: failed to open stream: HTTP wrapper does not support writeable connections. in /Applications/xampp/xamppfiles/htdocs/wordpress/wp-content/plugins/js_portfolio.php on line 93

 

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/var/tmp/phpjF23Ia' to 'http://localhost/wordpress/portfolio/Photo1.jpg' in /Applications/xampp/xamppfiles/htdocs/wordpress/wp-content/plugins/js_portfolio.php on line 93

There was an error uploading the small image, please try again!

Warning: move_uploaded_file(http://localhost/wordpress/portfolio/Photo1.jpgPhoto1.jpg) [function.move-uploaded-file]: failed to open stream: HTTP wrapper does not support writeable connections. in /Applications/xampp/xamppfiles/htdocs/wordpress/wp-content/plugins/js_portfolio.php on line 100

 

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/var/tmp/phpQyrKVx' to 'http://localhost/wordpress/portfolio/Photo1.jpgPhoto1.jpg' in /Applications/xampp/xamppfiles/htdocs/wordpress/wp-content/plugins/js_portfolio.php on line 100

There was an error uploading the large image, please try again!

 

 

get_option('port_url') = http://localhost/wordpress/portfolio/

 

PHP

 

$target_path = get_option('port_url');

	if(!file_exists($target_path))
	{					
		mkdir($target_path);					
	}

	/* Add the original filename to our target path.  
	Result is "uploads/filename.extension" */
	$target_path = $target_path . basename($_FILES['port_spic']['name']);
	if(move_uploaded_file($_FILES['port_spic']['tmp_name'], $target_path)) {
		$smallimage = $_FILES['port_spic']['name'];
	} else{
		print "There was an error uploading the small image, please try again!";
	}

	$target_path = $target_path . basename($_FILES['port_lpic']['name']);
	if(move_uploaded_file($_FILES['port_lpic']['tmp_name'], $target_path)) {
		$largeimage = $_FILES['port_lpic']['name'];
	} else{
		print "There was an error uploading the large image, please try again!";
	}

Link to comment
https://forums.phpfreaks.com/topic/76493-file-upload-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.