-1

I'm sure I'm missing something here but I'm not sure what. I am able to upload files to dropbox via a library. However the file is uploaded but the file is not recognized (viewable). Here are the details.

Library being used: Spatie\Dropbox\

My form to receive the upload(html):

<form action="http://127.0.0.1:8000/dropboxFileUpload" method="post" enctype="multipart/form-data">
    Select image to upload:
    <input type="file" name="uploadvideo" id="file">
    <input type="submit" value="Upload Image" name="submit">
</form>

My controller (actually in Laravel but I think it doesn't matter)

 public function dropboxFileUpload(Request $request)
  {
      $client = new Client(env('DROPBOX_TOKEN'));

      $name=$_FILES['uploadvideo']['name'];
      $type=$_FILES['uploadvideo']['type'];
      $cname=str_replace(" ","_",$name);
      $tmp_name=$_FILES['uploadvideo']['tmp_name'];
      $targetPath = 'justshoot/' . $cname;

      $upload = $client->upload($targetPath, $tmp_name);

      dd($tmp_name);
  }

in Dropbox the file gets posted to the directory and name as specified. In example if I upload 'myimage.jpg'. It appears in dropbox under justshoot/myimage.jpg.

The error says "Jpg is a recognizeable format but something went wrong", any idea what I'm doing wrong?

EDIT: I can confirm the file is good, I've also tried multi files, save thing.

FabricioG
  • 3,107
  • 6
  • 35
  • 74
  • Did you try to open the jpg file on your system? Did you try to upload it to Dropbox manually and try to reproduce the issue? It might be that the file is badly formatted and thus can't be interpreted as a jpg image by Dropbox. – Tomer Gal Dec 31 '19 at 20:33
  • @TomerGal the file is good, tested both ways. – FabricioG Dec 31 '19 at 20:34
  • might be missing the meta data files? What OS are you using? [This](https://www.dropboxforum.com/t5/Files-folders/quot-jpg-files-are-supported-but-something-went-wrong-quot/td-p/377528) may point you in the right direction. – Wilco Dec 31 '19 at 20:37
  • You're way off @Jdub, thanks for trying thou. – FabricioG Dec 31 '19 at 20:41

1 Answers1

0

The problem with my code above was that I wasn't actually getting the file content. I added this: $fileContent = file_get_contents($_FILES['uploadvideo']['tmp_name']);

Then did my call with the fileContent;

$upload = $client->upload($targetPath, $fileContent);
FabricioG
  • 3,107
  • 6
  • 35
  • 74