Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 07-01-2003, 08:01 AM
DeMuro1's Avatar
DeMuro1 DeMuro1 is offline
 
Join Date: Apr 2003
Location: A Golden State
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default saving images to a MySQL database

Is it even possible to save images to a MySQL database?

Basically, if someone E-Mails some fan art to website-staffer_1, I'd like them to be able to upload the image to the website. Is this possible?

If it is can someone let me know how

Thanks
Reply With Quote
  #2  
Old 07-05-2003, 11:37 AM
Gavin B. Gavin B. is offline
 
Join Date: Jul 2003
Location: Australia
Posts: 47
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes - this is how the vBulletin image upload features work at the moment. I'm more tempted to upload them to a directory however.

You can setup a simple form with a 'browse' button which allows users to upload images to a specified folder fairly easily which will upload and transfer the images to the folder. You can specify a pointer in mysql like /images/imagename.jpg
Reply With Quote
  #3  
Old 07-07-2003, 06:55 AM
DeMuro1's Avatar
DeMuro1 DeMuro1 is offline
 
Join Date: Apr 2003
Location: A Golden State
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

how would I go about setting up a directory that I could load into? I thought about just making the MySQL point to a folder but I don'r quite know how to do it.. Any suggestion would be greatlt appreciated
Reply With Quote
  #4  
Old 07-07-2003, 11:25 AM
Dean C's Avatar
Dean C Dean C is offline
 
Join Date: Jan 2002
Location: England
Posts: 9,071
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I've always wondered how people upload the files directly into the database though. I mean the attachments in vb aren't stored in a temporary directory are they?

I can create the form with a pointer to the file easily enough but uploading directly to the database is out of my league at the moment. Any tutorials or anything?

- miSt
Reply With Quote
  #5  
Old 07-07-2003, 06:59 PM
DeMuro1's Avatar
DeMuro1 DeMuro1 is offline
 
Join Date: Apr 2003
Location: A Golden State
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

my question as well. any help here would be greatly appreciated
Reply With Quote
  #6  
Old 07-08-2003, 03:21 AM
Gavin B. Gavin B. is offline
 
Join Date: Jul 2003
Location: Australia
Posts: 47
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try this:

You'll have to change the "newpath" line to match your own server (usually /home/youraccountusername/public_html/anotherfolder/)

anotherfolder is the folder that you want the imaged uploaded to, and it must be chmod'ed to 777

(only setup to upload jpg files atm though )

PHP Code:
<?
if($HTTP_POST_VARS['upload'])
{
    $userfile = $HTTP_POST_FILES['userfile']['tmp_name'];
    $userfile_name = $HTTP_POST_FILES['userfile']['name'];
    $userfile_size = $HTTP_POST_FILES['userfile']['size'];
    $userfile_type = $HTTP_POST_FILES['userfile']['type'];

    if($userfile != "" && $userfile_size != 0 && $userfile_type == "image/jpg" && is_uploaded_file($userfile)) {
        $newfile = "/home/pathto/public_html/yourfoldername/".$userfile_name;
        copy($userfile, $newfile);
        echo "Uploaded";
    }
}
?>

<html>
    <head>
        <title>Image Upload</title>
    </head>
    <body>

    <h1>Upload Image</h1>

    <form enctype="multipart/form-data" action="<?=$PHP_SELF?>" method="post">
        <input type="hidden" name="MAX_FILE_SIZE" value="200000">
        Select Your Image: <input name="userfile" type="file"><br />
        <input type="submit" name="upload" value="Upload Image">
    </form>

    </body>
</html>
Reply With Quote
  #7  
Old 07-08-2003, 10:44 AM
Dean C's Avatar
Dean C Dean C is offline
 
Join Date: Jan 2002
Location: England
Posts: 9,071
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You see i know how to do that nice and easily but can't u upload to an actual mysql database like in vb's attachments?

- miSt
Reply With Quote
  #8  
Old 07-08-2003, 11:16 AM
Gavin B. Gavin B. is offline
 
Join Date: Jul 2003
Location: Australia
Posts: 47
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I prefer it this way since it puts less load on mysql and doesn't mess around.

I think the main reason vB have done it through mysql is for compatability reasons, but I'm not 100% on that.
Reply With Quote
  #9  
Old 07-09-2003, 04:54 AM
Brad Brad is offline
 
Join Date: Nov 2001
Posts: 4,765
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

IMO its better to put them in a directory because it keeps the DB smaller.
Reply With Quote
  #10  
Old 07-09-2003, 06:17 AM
DeMuro1's Avatar
DeMuro1 DeMuro1 is offline
 
Join Date: Apr 2003
Location: A Golden State
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

wow holy smokes that's great. I might have a few questions about this a little later but that's great thanks a million

time for questions now.....I just can't deprioritize this

ok so this I take it stores the info in a directory...Right?

what is the directory name?

what is the file named or saved as...and is it possible to name the file manually, say by adding more form fields

if I wanted to allow the upload of more than one image at a time would it be possible with the use of a loop?

if I wanted to make a script that would upload this in a thumbnail form and then have a clickable thumbnail fo an enlarged image would I do that as I call the image to be displayed on the actual web page?

is there a way do view the directory say through the SmartFTP program I use and if so how do I do that

how can I modify this to upload different types of files?

do I just add a php/MySQL insert staement to insert the name into my database and then use it as a pointer?

Sorry for the 20 questions thing but I'm a little new to this and what you have there is greatly beyond what I know how to do. Can I give you credit by your name here when I open my site? I hate plagerism and theft
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:55 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04139 seconds
  • Memory Usage 2,246KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete