Jump to content

melting_dog

Members
  • Posts

    118
  • Joined

  • Last visited

    Never

Everything posted by melting_dog

  1. Hi all, Thanks for the responses. I had tried all that but now have found the issue. I should have mentioned first off - I am making a Wordpress Plugin and thus I have since found out WP needs to use certain 'tags'. So for WP plugins this is the correct path: $path = WP_PLUGIN_DIR."/prodadd/uploads/".$new_image_name; OR to get to the Wordpress Sites root: $path = ABSPATH."/uploads/".$new_image_name; Thanks all!
  2. Thanks for that. I have updated both those: //Form data sent $product_name = $_POST['product_name']; $product_active = $_POST['product_active']; $product_cat = $_POST['product_cat']; $product_desc = $_POST['product_desc']; $prod_inoutdoor = $_POST['prod_inoutdoor']; $prod_stackable = $_POST['prod_stackable']; $prod_discounted = $_POST['prod_discounted']; //IMAGE FILE $file_name = $_FILES['product_img']['name']; echo '<p>File Name:' . $file_name . '</p>'; //IMAGE UPLOAD // random 4 digit to add to file name $random_digit=rand(0000,9999); //combine random digit to you file name to create new file name //use dot (.) to combile these two variables $new_image_name = $random_digit.$file_name; echo $new_image_name; //SET DESINATION FOLDER $path= "http://localhost/website/uploads/".$new_image_name; echo '<p>Path:' . $path . '</p>'; if($product_img !=none) { if(move_uploaded_file($_FILES['product_img']['tmp_name'], $path)) { echo "Successful<BR/>"; echo "File Name :".$new_file_name."<BR/>"; echo "File Size :".$HTTP_POST_FILES['product_img']['size']."<BR/>"; echo "File Type :".$HTTP_POST_FILES['product_img']['type']."<BR/>"; } else { echo "Image upload Error<BR/>"; } However, I now get this error: move_uploaded_file(http://localhost/website/uploads/5965thailand.jpg) [function.move-uploaded-file]: failed to open stream: HTTP wrapper does not support writeable connections in I know this may have something to do with permissions. All permissions on that folder are set to read/write. This is obviously also running off my localhost. Can anyone give me an idea of why this is happening? Thanks heaps again!
  3. Hi guys, I am wirting a script to upload an image file, but I get the error: copy() [function.copy]: Filename cannot be empty in Obviouly it has something to do with the copy() function - (copy($HTTP_POST_FILES['product_img']['tmp_name'], $path)) I think it is not copying from my temp folder or something. Can anyone help me out? Code is: //IMAGE FILE $file_name = $_FILES['product_img']['name']; echo '<p>File Name:' . $file_name . '</p>'; //IMAGE UPLOAD // random 4 digit to add to file name $random_digit=rand(0000,9999); //combine random digit to file name to create new file name //use dot (.) to combile these two variables $new_image_name = $random_digit.$file_name; echo $new_image_name; //SET DESINATION FOLDER $path= "uploads/".$new_image_name; echo '<p>Path:' . $path . '</p>'; if($product_img !=none) { if(copy($HTTP_POST_FILES['product_img']['tmp_name'], $path)) { echo "Successful<BR/>"; echo "File Name :".$new_file_name."<BR/>"; echo "File Size :".$HTTP_POST_FILES['product_img']['size']."<BR/>"; echo "File Type :".$HTTP_POST_FILES['product_img']['type']."<BR/>"; } else { echo "Image upload Error<BR/>"; } } Any help would be greatly appreciated! Thanks
×
×
  • 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.