Took me 3 days to figure this out. Full, mind draining days. If I were paid to do this this info would cost at least 1200 EUR. This is for versions: FreeBSD 9.1 uwsgi 1.9.12 nginx 1.4.1 redmine 2.3.1 You’re pretty much left on your own in FreeBSD. Google results are terrible. 1. Problem: Rubygems…
Read ArticleCategory: Allgemein
Fixe Idee: 100GE Stadtnetze
Ich frage mich wieso wir Bürger nicht einfach selber ein Stadtnetz aufziehen statt alles privaten Unternehmen zu überlassen. Ich frage mich auch was sowas kosten würde in der Anschaffung und Instandhaltung. Und weiter wenn jede Stadt ein Bürgernetz und alle Netze untereinander verbunden sind. So das ich in, in meinem Fall Göppingen, mit jemandem in…
Read ArticleFile Uploads in PHP and in Symfony2
If you’re looking for an example: symfony2 file upload with related entities The PHP way: SQL
|
1 2 3 4 5 6 7 |
CREATE TABLE `file` ( `id` int(10) unsigned NOT NULL, `full_path` varchar(255) NOT NULL, `filename` varchar(255) NOT NULL, PRIMARY KEY (`id`), KEY `filename` (`filename`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
HTML
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
<!doctype html> <html> <body> <form method="post" enctype="multipart/form-data"> <input type="file" name="file[]" multiple> <button type="submit">Upload</button> </form> </body> </html> <?php $mysql = new mysqli('localhost','username','password','dbname'); $upload_dir = 'uploads'; $i = 0; foreach ($_FILES as $file) { if(is_uploaded_file($file['tmp_name']{$i})) { $destination = __DIR__ . DIRECTORY_SEPARATOR . $upload_dir . DIRECTORY_SEPARATOR . $file['name']{$i}; move_uploaded_file($file['tmp_name']{$i}, $destination); $mysql->query("INSERT INTO file (id, full_path, filename) VALUES (NULL,'" . $destination. "','" . $file['name']{$i} ."')"); } $i++; } ?> |
15 minutes later. Success. The symfony2 way: How to handle File Uploads with Doctrine Multiple File Uploads with Symfony2 Syntax Error. Head Explodes. 3 days later, time wasted. And this is why Symfony2 sucks. Can you…
Read Article