Jump to content

[SOLVED] Image Upload Help (HTTP wrapper does not support writeable connections)


NickG21

Recommended Posts

Hey everyone,

    I believe I'm aware of what the problem is and why im getting this error.  I read in other places online that it's because you can't write to an HTML URL directly and I understand that.  My question is how do I reference this upload to a different director containing the /images/ folder that i want them to be stored in.  Here is the error followed by my code for the upload and directory structure.

Thanks in advance for taking the time to look at this.

NickG

 

Error:

Warning: move_uploaded_file(http://www.yourlifeoutdoors.com/images/yourlife_logo_v1.jpg) [function.move-uploaded-file]: failed to open stream: HTTP wrapper does not support writeable connections in /home/alloutd1/public_html/admin/insertproduct.php on line 100

 

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/php0JgELx' to 'http://www.yourlifeoutdoors.com/images/yourlife_logo_v1.jpg' in /home/alloutd1/public_html/admin/insertproduct.php on line 100

Stored in: images/yourlife_logo_v1.jpg

 

Code:

<?php
if(isset($_POST['submit'])){

		if ((($_FILES["file"]["type"] == "image/gif")
		|| ($_FILES["file"]["type"] == "image/jpeg")
		|| ($_FILES["file"]["type"] == "image/pjpeg"))
		&& ($_FILES["file"]["size"] < 200000000))
		  {
		  if ($_FILES["file"]["error"] > 0)
		    {
		    echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
		    }
		  else
		    {
		    echo "Upload: " . $_FILES["file"]["name"] . "<br />";
		    echo "Type: " . $_FILES["file"]["type"] . "<br />";
		    echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
		    echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";

		    if (file_exists("http://www.yourlifeoutdoors.com/images/" . $_FILES["file"]["name"]))
		      {
		      echo $_FILES["file"]["name"] . " already exists. ";
		      }
		    else
		      {
		      move_uploaded_file($_FILES["file"]["tmp_name"],
Line 100:		      "http://www.yourlifeoutdoors.com/images/" . $_FILES["file"]["name"]);
		      echo "Stored in: " . "images/" . $_FILES["file"]["name"];
		      }
		    }
		  }
		else
		  {
		  echo "Invalid file";
		  }?>

the directory I would like the files stored in is yourlifeoutdoors.com/images/ but the page doing this insertion is located in an admin section of the site...  how do i reference to this directory?

Link to comment
Share on other sites

Based on the errors you are getting

<?php
move_uploaded_file($_FILES["file"]["tmp_name"],
"../images/" . $_FILES["file"]["name"]);
?>

 

Your viewpoint should be server directory structure, not web URL/Is

 

Also I believe this is the same for file_exists() that you are using too

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.