PDA

View Full Version : Create files from attachments


Scott MacVicar
03-04-2002, 10:00 PM
This is not like the attachments as files hack, it is simply a way to import files from the attachment table to real files for whatever reason, maybe you just wanted an actualy backup of the files instead of the database.

Simply upload the file into your admin directory.

Open up /admin/index.php

look for

makenavoption("Back-up Database","backup.php?action=choose","<br>");

below it add

makenavoption("Export Attachments","attachment_export.php?action=import","<br>");

done :)

M.Smith
03-05-2002, 06:44 PM
another useful hack from scott, the new mod

Jadelit
03-05-2002, 09:03 PM
I dunno if its just me, but when I press the link to it:

http://forums.jadelit.com/admin/attachment_export.php&s=6d2a081fa5f4a3ab0e24df9b210dbb83

it gives a 404, but when i go to

http://forums.jadelit.com/admin/attachment_export.php

it works fine...

?

Jawelin
03-05-2002, 09:30 PM
WoW!!! ;)
The long-awaited stand alone exporter !!! Great!
(Scott, do you remember our thread about in beta ? ;) )

This point, seems it's missing only the 2-way converter, if anyone would come back to the db-version of attachments...
:D :D :D :D :D :D :D
I'm jokin'... of course.
Great job as usual.
Bye

Scott MacVicar
03-05-2002, 09:30 PM
em i missed the action bit, re-apply the change to your /admin/index.php from the first post

Scott MacVicar
03-05-2002, 09:38 PM
On a side note, this hack RELIES on two files not having the same name, if they do it will just rewrite the first one with later ones.

Jadelit
03-05-2002, 09:47 PM
ok great, thanks

Lucky
03-05-2002, 11:12 PM
Are you sure that this:
if ($action == "import") {
doformheader("attachment_import","doimport");
maketableheader("Add New Forum");

Shouldn't be this:
if ($action == "import") {
doformheader("attachment_export","doimport");
maketableheader("Add New Forum");

Aaow AnD wHiTe
03-06-2002, 08:53 AM
Thx Scott :) This is our first request that has actually turned into a hack, LOL!!

Thanx buddy, gonna use it right away ;)

Aaow AnD wHiTe
03-06-2002, 09:22 AM
Well, it has worked really well... Now we have a HUGE folder with a LOT of attachments! :D

Would it be possible to make a zipped output of the backup instead of all the files in one folder?

Thanx again for the hack ;)

Scott MacVicar
03-06-2002, 10:28 AM
nope thats definately beyhond the limitations of php, yes it wouldn't be hard to zip a couple of files, but it would have a limit of about 30mb worth of files as if you tried to zip any more i'm sure that php would run out of memory.

You can simply tar then gzip it in shell

tar -cvf attachments.tar attachments
gzip attachments.tar

and you get attachments.tar.gz

Tim Wheatley
03-06-2002, 06:56 PM
Does this export all files, or can you choose only certain attachments? I don't want people to be able to download all the file without having to do some through the board (because it gives download counts).

Scott MacVicar
03-06-2002, 07:43 PM
It exports all files, though I'm workin on an attachment manager which allows you to manipulate attachments via the admin panel, delete attachments, view attachments, rename attachment, make attachment to file or upload a new attachment. You can also sort the attachments via size and search and other things really.

Tim Wheatley
03-07-2002, 07:25 PM
Oh that's great thanks :)

If you need a beta tester let me know ;)

Scrooge
03-07-2002, 08:56 PM
I'm getting the following error:

Warning: fopen("/home/reefaqua/public_html/forums/attachments/hermit crab small.jpg", "wb") - Permission denied in /home/reefaqua/public_html/forums/admin/attachment_export.php on line 32

Warning: Supplied argument is not a valid File-Handle resource in /home/reefaqua/public_html/forums/admin/attachment_export.php on line 33

Any ideas?

Scott MacVicar
03-07-2002, 09:59 PM
chmod the attachments folder to 666

Admin
03-08-2002, 12:07 PM
w00t now I have a huge folder with all attachments. That was fun... :D

eva2000
03-10-2002, 10:49 AM
PPN i love this hack!!

i wanted this for sooooooooooooo long.. actually check out my sig request at https://vborg.vbsupport.ru/showthread.php?s=&threadid=32024

maybe a further extension of this hack ? :)

eva2000
03-10-2002, 10:56 AM
does this hack actually delete the original attachments in the database or keeps them after exporting?

looked at my attachment table and it's 225mb in size!

Scott MacVicar
03-10-2002, 10:58 AM
It leaves them in the database though if you want to have all attachments as files instead ot the databse then look in my huge long sig and the attachments as files imports all the attachments and when you upload attachments it puts them into a folder.

I could do the forum gallery hack but I have too little time spread too thinly (is that a word?)

Scott MacVicar
03-10-2002, 11:00 AM
https://vborg.vbsupport.ru/showthread.php?s=&threadid=35193 is the URL and boy that last post was screwed up, sorry for my bad english :) thats what you get when your first language is gaelic

eva2000
03-10-2002, 12:22 PM
Originally posted by PPN
It leaves them in the database though if you want to have all attachments as files instead ot the databse then look in my huge long sig and the attachments as files imports all the attachments and when you upload attachments it puts them into a folder.

I could do the forum gallery hack but I have too little time spread too thinly (is that a word?) your sig looks weird in 800x600 15" monitor

Scott MacVicar
03-10-2002, 02:42 PM
I done it in 1024 x 768 :D

well chen done it, I had it all on a new line but my sig was getting a bit long lol

I might make it an image, though I wonder if i could write some vBcode to allow the use of image maps

Raptor
04-18-2002, 12:48 AM
i get:

Warning: fopen("/sites/d/digital-forums.com/htdocs/www/attatchments/wet.zip", "wb") - Permission denied in /sites/d/digital-forums.com/htdocs/www/forum/admin/attachment_export.php on line 32

Warning: Supplied argument is not a valid File-Handle resource in /sites/d/digital-forums.com/htdocs/www/forum/admin/attachment_export.php on line 33

Imported wet.zip

and yes i chmod correctly to 666

Admin
04-18-2002, 10:44 AM
You need to CHMOD 0777, no?

Raptor
04-22-2002, 01:55 PM
Warning: fopen("/sites/d/digital-forums.com/htdocs/attach/eval-corp.gif", "wb") - No such file or directory in /sites/d/digital-forums.com/htdocs/www/forum/admin/attachment_export.php on line 31

Warning: Supplied argument is not a valid File-Handle resource in /sites/d/digital-forums.com/htdocs/www/forum/admin/attachment_export.php on line 32

now I get this message

any clues ?

Raptor
04-22-2002, 01:56 PM
PS im using 2.2.4

Scott MacVicar
04-22-2002, 02:01 PM
you definately created the attach folder and chmod it to 0777 this is vital as the problem is definately with permissions, this is the only reason it would stop attachments from being created.

Raptor
04-22-2002, 03:57 PM
yes definatley

after some tweeking it now says import successful (no erroes) but theres no files in the folder

very very strange ?

Scott MacVicar
04-22-2002, 05:26 PM
what do you mean by tweaking?
changing the file or the permissions?

Raptor
04-23-2002, 07:00 AM
hard coded the root path

the script sumps the files - but all i can see is the folders growing in size but there is nothing in the folders

im tearing my hair out !!!

KuraFire
05-09-2002, 12:45 PM
eventually, I got it to work. Thanks, good hack! :):up:

sharkito
07-22-2002, 04:42 PM
Is there a way to do the reverse thing, to import the files in the database ???
That would be helpfull since i have to backup all my forum manually due to my crap host ;-\

Great hack btw :)

Scott MacVicar
07-23-2002, 11:21 AM
I will see what i can do.

joor
11-17-2002, 05:36 PM
Worked great, thanks.

sebastian406
06-28-2003, 01:24 AM
I installed the hack, but haven't used it yet. If i use it, will it remove the files from the database, or just copy them? Thanks.

Harlen
08-06-2003, 05:43 PM
Iam getting the followring error when trying to export files from Database

Please help, Thanks

Warning: fopen(/usr/local/apache/htdocs/mydomain.com/attachments/untitled.gif) [function.fopen]: failed to create stream: No such file or directory in /usr/local/apache/htdocs/exriders.com/vbb/admin/attachment_export.php on line 32

Warning: fwrite(): supplied argument is not a valid stream resource in /usr/local/apache/htdocs/mydomain.com/vbb/admin/attachment_export.php on line 33

jjj0923
08-06-2003, 05:52 PM
Today at 02:43 PM Harlen said this in Post #37 (https://vborg.vbsupport.ru/showthread.php?postid=423874#post423874)
Iam getting the followring error when trying to export files from Database

Please help, Thanks


Warning: fopen(/usr/local/apache/htdocs/mydomain.com/attachments/untitled.gif) [function.fopen]: failed to create stream: No such file or directory in /usr/local/apache/htdocs/exriders.com/vbb/admin/attachment_export.php on line 32

Warning: fwrite(): supplied argument is not a valid stream resource in /usr/local/apache/htdocs/mydomain.com/vbb/admin/attachment_export.php on line 33


sound like the directory does not exist or is not set to 777.

- jeff