Jump to content

Recommended Posts

This foreach loop in my function isnt working. It only moves the pictures when $image_temp is one picture, but when $image_temp is an array, i thought it should loop around again and move the other images. i cant seem to figure out why it isnt looping around again.

heres the function.

 

function addcar_uploaddata($num_rows,$image_ext,$image_temp,$user_id,$car_data){
	$user_id = (int)$user_id;
	array_walk($car_data, 'array_sanitize');



	$fields = '`' . implode('`, `', array_keys($car_data)) . '`';
	$data = '\'' . implode('\', \'', $car_data) . '\'';

	mysql_query("INSERT INTO cars ($fields) VALUES ($data)");
		$num_rows = $num_rows + 1;
		$car_id = mysql_insert_id();
		$car_file = $car_id . '.' . $image_ext;
		mkdir('uploads/cars/' . $_SESSION['user_id'] . '/car' . $num_rows,0744);
		mkdir('uploads/cars/' . $_SESSION['user_id'] . '/thumbs',0744);
		foreach($image_temp as $image_temps){
			move_uploaded_file($image_temps, 'uploads/cars/' . $_SESSION['user_id'] . '/car' . $num_rows . '/' . $car_file);
			create_thumb('uploads/cars/' . $_SESSION['user_id'] . '/' . 'car' . $num_rows , $car_file, 'uploads/cars/' . $_SESSION['user_id'] . 'thumbs/',150,150);
		}
	}

 

allot of the function you dont need to see but i put it in anyway

Link to comment
https://forums.phpfreaks.com/topic/268491-moving-multiple-pictures-problem/
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.