public function upload() { $folder = date('Y/m/', time()); $config['upload_path'] = '../data/' . $folder; //判断此文件夹是否存在,不存在则进行创建 if (!is_dir($config['upload_path'])) { mkdir($config['upload_path'], 0755, TRUE); } $config['allowed_types'] = 'doc|docx|xls|xlsx|ppt|pptx|pdf'; $config['max_size'] = '2048'; $config['encrypt_name'] = TRUE; $this->load->library('upload', $config); if (!$this->upload->do_upload('file')) { $this->session->set_flashdata('msg', $this->upload->display_errors('', '')); redirect(); } else { $uploaded = $this->upload->data(); $doc = array(); $doc['name'] = str_replace($uploaded['file_ext'], '', $uploaded['orig_name']); $doc['type'] = str_replace('.', '', $uploaded['file_ext']); $doc['size'] = $uploaded['file_size']; $doc['origin_path'] = $folder . $uploaded['file_name']; $doc['path'] = ''; $doc['status'] = 'pending'; if ($this->db->insert('docs', $doc) and $doc_id = $this->db->insert_id()) { $queue_data = json_encode(array('id' => $doc_id, 'folder' => $folder, 'raw_name' => str_replace($uploaded['file_ext'], '', $uploaded['file_name']), 'name' => $uploaded['file_name'])); //将文件入转换队列 include FCPATH . '../scripts/httpsqs/httpsqs_client.php'; $httpsqs = new httpsqs('127.0.0.1', 1218); if ($doc['type'] === 'pdf') { $httpsqs->put('pdf2swf', $queue_data); } else { $httpsqs->put('office2pdf', $queue_data); } $this->session->set_flashdata('msg', '文件上传成功.'); redirect(); } else { $this->session->set_flashdata('msg', '上传失败'); redirect(); } } }
<?php include_once "httpsqs_client.php"; $httpsqs = new httpsqs("127.0.0.1", 1218, "mypass123", "utf-8"); $message = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaaaa"; $number = 20000; /* test queue put */ echo "Test Queue PUT, please waitting ...\n"; $start_time = microtime(true); for ($i = 1; $i <= $number; $i++) { $httpsqs->put("command_line_test", $i . $message); } $run_time = microtime(true) - $start_time; echo "PUT " . $number . " messages. Run Time for Queue PUT: {$run_time} sec, " . $number / $run_time . " requests/sec\n"; ob_flush(); /* test queue get */ echo "Test Queue GET, please waitting ...\n"; $start_time = microtime(true); for ($i = 1; $i <= $number; $i++) { $result = $httpsqs->get("command_line_test"); //echo($result."\n"); } $run_time = microtime(true) - $start_time; echo "GET " . $number . " messages. Run Time for Queue GET: {$run_time} sec, " . $number / $run_time . " requests/sec\n";
<?php include_once "httpsqs_client.php"; $httpsqs = new httpsqs(); $result = $httpsqs->put("127.0.0.1", 1218, "utf-8", "your_queue_name1", urlencode("text_message1")); echo "###1.put result:\r\n"; var_dump($result); echo "\r\n\r\n"; $result = $httpsqs->get("127.0.0.1", 1218, "utf-8", "your_queue_name1"); echo "###2.get result:\r\n"; var_dump($result); echo "\r\n\r\n"; $result = $httpsqs->put("127.0.0.1", 1218, "utf-8", "your_queue_name1", urlencode("text_message2")); echo "###3.put result:\r\n"; var_dump($result); echo "\r\n\r\n"; $result = $httpsqs->gets("127.0.0.1", 1218, "utf-8", "your_queue_name1"); echo "###4.gets result:\r\n"; var_dump($result); echo "\r\n\r\n"; $result = $httpsqs->pput("127.0.0.1", 1218, "gb2312", "your_queue_name2", urlencode("text_message3")); echo "###5.pput result:\r\n"; var_dump($result); echo "\r\n\r\n"; $result = $httpsqs->pget("127.0.0.1", 1218, "gb2312", "your_queue_name2"); echo "###6.pget result:\r\n"; var_dump($result); echo "\r\n\r\n"; $result = $httpsqs->status("127.0.0.1", 1218, "utf-8", "your_queue_name1"); echo "###7.status result:\r\n"; var_dump($result);
<?php include_once "httpsqs_client.php"; $httpsqs = new httpsqs("127.0.0.1", 1218, "mypass123", "utf-8"); $result = $httpsqs->put("your_queue_name1", urlencode("text_message1")); echo "###1.put result:\r\n"; var_dump($result); echo "\r\n\r\n"; $result = $httpsqs->get("your_queue_name1"); echo "###2.get result:\r\n"; var_dump($result); echo "\r\n\r\n"; $result = $httpsqs->put("your_queue_name1", urlencode("text_message2")); echo "###3.put result:\r\n"; var_dump($result); echo "\r\n\r\n"; $result = $httpsqs->gets("your_queue_name1"); echo "###4.gets result:\r\n"; var_dump($result); echo "\r\n\r\n"; $result = $httpsqs->status("your_queue_name1"); echo "###5.status result:\r\n"; var_dump($result); echo "\r\n\r\n"; $result = $httpsqs->status_json("your_queue_name1"); echo "###6.status_json result:\r\n"; var_dump($result); echo "\r\n\r\n"; $result = $httpsqs->view("your_queue_name1", 1); echo "###7.view result:\r\n"; var_dump($result);