I've solved the resource problem, but ran into another one:
The picture to be stored in the db appear in the variable $data as a long string of crap. I recieve a mysql syntax error message. Code:
$data = addslashes($data);
mysql_query("INSERT INTO v2_products (pic1) VALUES ('$data'") or die (mysql_error());
Error message: Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1