Corrupted file when saving to bd - PHP

Asked

Viewed 22 times

0

need help.

I have a system that needs to upload a file to the comic book. The system stores the image bin in the database instead of creating a file reference on the server. This bin is corrupted, the image does not open.

Follows the code:

$anexo = $_FILES['anexo'];
$img_bin = addslashes(fread(fopen($_FILES['anexo']['tmp_name'], "r"), filesize($_FILES['anexo']['tmp_name'])));

$class_model->setImg_Bin($img_bin);
  • 1

    How is your database configured, especially the column that will receive the data? Why did you set the variable $anexo if subsequently used $_FILES anyway? How did you verify that the data got corrupted?

  • The thing is, do you know Ocomon? Here in the company this system is used, and a web page was developed with a simple form for the user to create an occurrence. The Ocomon form saves correctly, the form saved with error. I did tests with the same image, the generated bin are different. I already checked all the charset of both pages, everything is the same. Obg.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.