You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.
Forum Discussion
GeekDesign
6 years agoExplorer | Level 4
Dropbox multiple file upload API hanging at the end?
Hello, I am working on API integration on a website, we need to upload multiple files at once. I am not the programmer and have limited knowledge of the mather. I am working with a fourign company ...
- 6 years ago
GeekDesign Thanks for sharing this code. Unfortunately however, it appears that some of the actual Dropbox API calling code is hidden in methods that aren't defined in this snippet (e.g., check_dropbox_file, upload_dropbox_file, check_dropbox_folder, and create_dropbox_folder), so it's harder to say exactly what it's doing.
Likewise, I don't see any reference to a progress bar here, so I can't say what exactly is driving it or when.
Please have your developers review their code and let us know what exactly isn't working as expected (if anything) so we can offer some guidance. Thanks!
Greg-DB
Dropbox Staff
Unfortunately it's difficult to reason about what is happening here without more specific information/code. Can you or your development company inspect the code driving the progress meter, and follow up here with any other details or code you can share if something isn't working as expected? Thanks in advance!
GeekDesign
6 years agoExplorer | Level 4
Hello, Greg, sorry for the late responce, took some time to get the code:
public function upload_image() { check_login('after_login', 2); if ($this->input->post()) { $project_id = $this->input->post('project_id'); $find_project = $this->ProjectModel->get_project_details_by_id($project_id); if (empty($find_project)) { echo 'not_found'; exit; } $project_date = $find_project[0]['created']; $product_id = $this->input->post('product_id'); $project_products_id = $this->input->post('project_products_id'); $product_details = $this->ProductModel->find_product($product_id); $product_uploads = $this->ProductModel->get_product_logos_for_user_product($this->session->userdata('id'), $product_id); $file_data = $this->input->post('file_data'); $file_name = $this->input->post('file_name'); $attachment_type = $this->input->post('attachment_type'); $type = explode('.', $file_name); // $image_name = $type[0] . '_' . date('Ymdhis') . '_' . rand(111, 999) . '.' . $type[1]; $path_str = trim($find_project[0]['storage_name']) . "/raw material/" . $attachment_type; $dropox_uploadPath = create_dropbox_path($project_date, $path_str); $dropbox_common_file_path = create_dropbox_path($project_date, trim($find_project[0]['storage_name']) . "/raw material"); if (isset($_FILES['file_data'])) { $headers = array('Authorization: Bearer ' . $this->session->userdata('drop_box_api'), 'Content-Type: application/json'); foreach ($product_uploads as $upload_id => $upload_data): $dropox_exist = check_dropbox_file($headers, $dropbox_common_file_path . '/' . basename($upload_data['path'])); if (isset($dropox_exist->error)) { $upload_headers = array('Authorization: Bearer ' . $this->session->userdata('drop_box_api'), 'Content-Type: application/octet-stream', 'Dropbox-API-Arg: ' . json_encode( array( "path" => $dropbox_common_file_path . '/' . basename($upload_data['path']), "mode" => "add", "autorename" => true, "mute" => false, "strict_conflict" => false ) ) ); $new_upload = upload_dropbox_file($upload_headers, './assets/images/product_logos_clients/' . $product_uploads[0]['path']); } endforeach; $folder_name = $dropox_uploadPath; //Chek if folder exist in drop box $find_folder = check_dropbox_folder($headers, $folder_name); if (isset($find_folder->error)) { //Create folder in drop box if not exist $my_folder_create = create_dropbox_folder($headers, $folder_name); if (isset($my_folder_create->error)) { echo 'fail'; exit; } } foreach ($_FILES['file_data']['name'] as $key => $filename) { $image_name_upload = $filename; $tmp = $_FILES['file_data']['tmp_name'][$key]; $headers = array('Authorization: Bearer ' . $this->session->userdata('drop_box_api'), 'Content-Type: application/octet-stream', 'Dropbox-API-Arg: ' . json_encode( array( "path" => $folder_name . '/' . basename($image_name_upload), "mode" => "add", "autorename" => true, "mute" => false, "strict_conflict" => false ) ) ); //Upload file to dropbox $uploaded_image = upload_dropbox_file($headers, $tmp); if (isset($uploaded_image->error)) { echo 'fail'; exit; } $store_attached['product_id'] = $product_id; $store_attached['project_id'] = $project_id; $store_attached['project_products_id'] = $project_products_id; if ($this->input->post('project_products_id') && $this->input->post('project_products_id') != '' && $this->input->post('project_products_id') != 0) { $store_attached['project_products_id'] = $this->input->post('project_products_id'); } $store_attached['dropbox_path'] = $uploaded_image; $store_attached['is_rawmaterial'] = 0; $save_attachment = $this->ProjectModel->save_attachment($store_attached); if (!$save_attachment) { echo 'fail'; } else { $history_data = array(); $history_data['operation'] = 'uploaded_raw'; $history_data['project_id'] = $product_id; $history_data['product_id'] = $project_id; $history_data['by_user'] = $this->session->userdata('id'); $add_history = $this->ProjectModel->save_history($history_data); echo 'success'; } } } } exit; }
The basic idea was for fotographers to upload via web, and the files would be placed in our dropbox automatically. So they would create the address of the house they shot, and pick what they shot (photos, 360 photos or something else) and they would get a corresponding field to upload those photos.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,919 PostsLatest Activity: 9 hours ago
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!