0

I'm trying to save a PDF file in MySQL but It doesn't work. It seems Symfony and Doctrine are not able to save a file in blob row...

When I submit my form with the file, everything seems ok. But when I download the file from my database I have this:

/tmp/phpssT5KJ

It's like the blob row was the path of my file?

All my google research provide a way for moving a file but I don't want to move my file to /web/{something}...

Is it possible? Why my row contains the path instead of the file?

Best regards,

2 Answers 2

1

So I found how to fix it:

Like the usual method when you save only the path you add a variable $file and the method upload. (On your form you use $file and not your field)

Upload needs this code:

public function upload(){  
    $pdfFile = $this->file;   
    $this->setPdf(file_get_contents($pdfFile));
} 
Sign up to request clarification or add additional context in comments.

Comments

0

That path is path to your TMP location of the file. You need to put that files content in your DB.

1 Comment

I know that path is the TMP location of the file... But why Symfony/Doctrine puts the path instead of the file in my DB? How can I put the file if Symfony/Doctrine don't?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.