vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   saving images to a MySQL database (https://vborg.vbsupport.ru/showthread.php?t=54909)

DeMuro1 07-01-2003 08:01 AM

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

Gavin B. 07-05-2003 11:37 AM

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 :)

DeMuro1 07-07-2003 06:55 AM

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

Dean C 07-07-2003 11:25 AM

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

DeMuro1 07-07-2003 06:59 PM

my question as well. any help here would be greatly appreciated

Gavin B. 07-08-2003 03:21 AM

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>


Dean C 07-08-2003 10:44 AM

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

Gavin B. 07-08-2003 11:16 AM

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.

Brad 07-09-2003 04:54 AM

IMO its better to put them in a directory because it keeps the DB smaller.

DeMuro1 07-09-2003 06:17 AM

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


All times are GMT. The time now is 07:52 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.01867 seconds
  • Memory Usage 1,737KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete