Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $file_name = "photo_export_file.v3.csv";
- if (($handle = fopen($file_name, "r")) !== FALSE) {
- while (($data = fgetcsv($handle, 100, ";")) !== FALSE) {
- $values = "('".$data[2]."', '".$data[3]."', '".$data[4]."', ";
- $pic_path = substr($data[1], 1);
- $pic_name = array_pop(explode("/", $data[1]));
- $pic_name = strtolower($pic_name);
- $values .= "'".$pic_name.":image/jpeg:".filesize($pic_path).":".$data[2]."/".$data[3]."/".$pic_name."', ";
- $thumb_path = substr($data[0], 1);
- $thumb_name = array_pop(explode("/", $data[0]));
- $thumb_name = strtolower($thumb_name);
- $values .= "'".$thumb_name.":image/jpeg:".filesize($thumb_path).":".$data[2]."/".$data[3]."/".$thumb_name."')";
- $que = "INSERT INTO Message2005 (Subdivision_ID, Sub_Class_ID, AlbumID, Picture, Preview) VALUES ".$values;
- # if (!file_exists($pic_path) or !file_exists($thumb_path)) {
- # echo "no ".$pic_path."or no ".$thumb_path."\n";
- # }
- # else {
- if (!file_exists("netcat_files/".$data[2]."/".$data[3])) {
- //mkdir("netcat_files/".$data[2]) or die("could not create dir netcat_files/".$data[2]);
- mkdir("netcat_files/".$data[2]."/".$data[3], 0777, true) or die("could not create dir netcat_files/".$data[2]."/".$data[3]);
- }
- rename($pic_path, "netcat_files/".$data[2]."/".$data[3]."/".$pic_name) or die("could not move ".$pic_path."to netcat_files/".$data[2]."/".$data[3]."/".$pic_name);
- rename($thumb_path, "netcat_files/".$data[2]."/".$data[3]."/".$thumb_name) or die("could not move ".$thumb_path);
- mysql_query($que) or die(mysql_error());
- echo mysql_insert_id()." successful\n";
- //echo $que."\n";
- # }
- }
- fclose($handle);
- }
- else echo "could not open file";
Advertisement
Add Comment
Please, Sign In to add comment