0

I'm developing an e-project website in php and mysql. I have a problem in saving a video as longblob. It has a minimum size of 2MB. So, every time when an Admin has to update his web pages, he has to compress his videos. And that wouldn't be nice. Is it possible to save a video as path? I've done something similar to that in C#.NET, but I haven't tried in php.

deepz
  • 73
  • 2
  • 10
  • wild guessing mode: By "I've done something similar to that in C#.NET" you're refering to sql server's FILESTREAM storage? – VolkerK Sep 01 '11 at 08:38
  • Does "video as path" mean, you just want to store a simple string like "this/is/my/video.webm"? I would go with that idea, instead storing video content in a database. Thats what file servers are for. – feeela Sep 01 '11 at 08:40
  • I was refering to C#, where I create a folder in my solution explorer. And whatever path I select after an Open dialog box appears, the video saves in the folder and the path saves in SQL server – deepz Sep 01 '11 at 08:42
  • You can do this with php, too. see e.g. http://docs.php.net/mkdir and http://docs.php.net/move_uploaded_file – VolkerK Sep 01 '11 at 08:46
  • store them in a folder, and put the filename in database. when you fetch them, link to the video using that filename – Dreaded semicolon Sep 01 '11 at 08:47
  • I've gone through those links. Thanks. It's my first time to do such stuff in php. So, where should I put that folder for saving videos? In my website folder or should I let php create that folder in the location where the Admin selects? – deepz Sep 01 '11 at 08:57

1 Answers1

3

every time when an Admin has to update his web pages, he has to compress his videos

Why? It's perfectly possible to update a row in the database without changing a BLOB that's already in there.

Is it possible to save a video as path?

Certainly. Blob vs File is a trade-off that you'll have to decide depending on your app's needs. See eg this question for background.

Community
  • 1
  • 1
bobince
  • 528,062
  • 107
  • 651
  • 834
  • So what you're saying is..even if the size of a video is huge, It saves without any problem? – deepz Sep 01 '11 at 08:46
  • Yes, storing and retrieving large BLOBs is not a problem for any modern database (it's arguable whether it's a good idea for really large ones, but 2MB isn't that big). – bobince Sep 01 '11 at 08:55
  • I have videos exceeding that size limit. – deepz Sep 01 '11 at 08:58
  • It's not a limit. 2MB is not that big. But if you are talking about a MySQL LONGBLOB you may need to set the [`max-allowed-packet`](http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#sysvar_max_allowed_packet) config to a larger value to accommodate it. – bobince Sep 01 '11 at 09:13
  • Same way as any other column, using a string literal that's gone through `mysql_real_escape_string` (or, better, using parameterised queries). – bobince Sep 01 '11 at 09:25
  • Please explain.. I don't know how to do that. – deepz Sep 01 '11 at 09:30
  • Sounds like you need a basic PHP+MySQL tutorial then. Here's [a random one](http://dsc.sun.com/databases/articles/mysql_php1.html) using mysqli and parameterised queries. (In this case you have to tell it you're using a BLOB rather than a character string by using `'b'` as a format specifier rather than `'s'`.) – bobince Sep 01 '11 at 12:09
  • I read the contents in that link ,thanks..it helped me alot :) you just solved my doubt. – deepz Sep 02 '11 at 07:55