Jump to content

[SOLVED] file uploading


swissbeets

Recommended Posts

i have a back end part to my site so someone can easily update the products.  i want it to be able to save pictures from my desktop in my website images folder

 

ithought it worked but it definitely doesnt  i  am pretty sure its because the images arent saving right

 

here is my code i took it from a tutorial and based it to needs

 

<?php require_once("includes/session.php"); ?>
<?php require_once("includes/connection.php"); ?>
<?php require_once("includes/functions.php"); ?>
<?php confirm_logged_in(); 
//echo "<pre>";
//print_r($_FILES);
//echo "</pre>";
$target_path = "images\ ".$_FILES['uploadedfile']['name'];
move_uploaded_file($_FILES['uploadedfile']['tmp_name'],$target_path);
$image_source = mysql_prep($_FILES['uploadedfile']['name']);
$id = $_GET['prod'];
$query = "UPDATE products SET 
						image_source = '$image_source'
					WHERE product_id = $id";
//print $query;
			$result = mysql_query($query);
			if (mysql_affected_rows() == 1) {
				redirect_to("edit_product.php");
			} else {
				// Failed
				$message = "The product update failed.";
				$message .= "<br />". mysql_error();
			}?>

 

does anyone see anything i am doing wrong?

Link to comment
https://forums.phpfreaks.com/topic/115632-solved-file-uploading/
Share on other sites

"Aren't saving right"

 

 

what are they pictures of mickey mouse when you uploaded donald duck? Are they just not there? Have they moved folder? Be specific. DO you have the include pages? Also, if its a tutorial, then it 99% works. Make sure you did everything exact. If it still doesn't work, then its a problem with th tutorial code. Contact the author of it if its a genuine problem.

 

Upon reading your code...what the hell??? this has nothing to with image UPLOADING....please rephrase your question.

i kind of assumed that

 

"$target_path = "images/ ".$_FILES['uploadedfile']['name'];

move_uploaded_file($_FILES['uploadedfile']['tmp_name'],$target_path);

$image_source = mysql_prep($_FILES['uploadedfile']['name']);

"

 

was moving a file, is it not?

 

my code  (i thought) was saving the file in my images folder and then saving the name in my database is that not what this is doing with the uploader? if not what is it doing?

 

 

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.