Register Members List Search Today's Posts Mark Forums Read

Reply
 
Article Options
Upload images using the datamanager.
waza
Join Date: Apr 2005
Posts: 341

Made in belgium

Belgium
by waza waza is offline 03 Mar 2006

Hey,
In this tutorial I'll try to show you how you can upload images using the vb datamanaging class.

First of all you have to make a special form to upload images.
Like this:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

So make sure you have this:
<form method="post" enctype="multipart/form-data">
and <input type="file" name="upload">

then you can create a php file to process the upload.
like this:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

So this:
$vbulletin->input->clean_gpc("f","upload",TYPE_FILE); cleans the file
$upload->path is the path to where the image has to be uploaded
$vbulletin->GPC['upload'] is the file containing ($vbulletin->GPC['upload'][x]):
-name: The name of the image
-type: the mime type of the image, like: image/gif
-tmp_name: the temporary name when the image is uploading
-size: the filesize in bytes

I hope this can help you
regards,
seba
Views: 7108
Reply With Quote
Comments
  #2  
Old 03 Mar 2006, 19:47
DrewM DrewM is offline
 
Join Date: Oct 2005
Asome thanks
__________________
SiteSmart
Reply With Quote
  #3  
Old 22 Apr 2006, 22:32
Impreza04's Avatar
Impreza04 Impreza04 is offline
 
Join Date: Jul 2005
Thanks for the tutorial, problem is that it doesn't check for files with the same name and just overwrites them.

Anyone know a way around this
Reply With Quote
  #4  
Old 01 May 2006, 07:05
SiMateoAko SiMateoAko is offline
 
Join Date: Apr 2006
Originally Posted by Impreza04
Thanks for the tutorial, problem is that it doesn't check for files with the same name and just overwrites them.

Anyone know a way around this
Not sure of the exact code, but how about uploading it to a temp directory, giving it a new filename and then moving it to the proper directory?
Reply With Quote
  #5  
Old 04 Nov 2006, 19:37
johnstires johnstires is offline
 
Join Date: Mar 2006
I'd like to create something like this, but the problem I'm having with the directions is where does everything go? Where do I place the html and php code?
Reply With Quote
  #6  
Old 29 Jan 2007, 15:31
timedgar timedgar is offline
 
Join Date: Jan 2007
I'm wondering if the class has features to put the image right into the DB. I know there is debate about doing that, but I like it for small things like product images, etc.

Also, are functions included for displaying the image, either out of the DB or from disk? 'twould be nice.


Thanks,

Tim
Reply With Quote
  #7  
Old 28 Jun 2008, 14:43
aussiev8 aussiev8 is offline
 
Join Date: Aug 2004
I know this is really old.. but to change the filename you can simply
$vbulletin->GPC['upload']['name'] = "blah";
This could cause unexpected bugs..
best thing to do is attempt to separate the files into directories.. maybe by user/thread/etc. etc.
Reply With Quote
  #8  
Old 21 Sep 2008, 20:17
mokujin's Avatar
mokujin mokujin is offline
 
Join Date: Nov 2005
Real name: Đạt
Originally Posted by aussiev8 View Post
I know this is really old.. but to change the filename you can simply
$vbulletin->GPC['upload']['name'] = "blah";
This could cause unexpected bugs..
best thing to do is attempt to separate the files into directories.. maybe by user/thread/etc. etc.
With this I couldnt rename that file I just uploaded.
Can someone help me with renaming the file?
thank you so much
Reply With Quote
  #9  
Old 15 Feb 2009, 01:57
Jaxel Jaxel is offline
 
Join Date: Sep 2005
I'm having problems using this... this is my code...


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

This should work... but I'm getting the following error...

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Any ideas? I am uploading a file called sc4.jpg...
Reply With Quote
  #10  
Old 21 Feb 2009, 07:03
ragtek's Avatar
ragtek ragtek is offline
 
Join Date: Mar 2006
Location: austria, croatia
shouldn't this thread also be in the vb area and not programming?
__________________
my addons: http://ragtek.github.com
Reply With Quote
  #11  
Old 22 Feb 2009, 13:01
bananalive bananalive is offline
 
Join Date: Oct 2007
Real name: Dom
Originally Posted by Jaxel View Post
I'm having problems using this... this is my code...


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

This should work... but I'm getting the following error...

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Any ideas? I am uploading a file called sc4.jpg...

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

__________________
Reply With Quote
  #12  
Old 08 Mar 2009, 04:46
rob01 rob01 is offline
 
Join Date: Sep 2008
Real name: robert
is it possible to show the images uploaded inside the page?
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Article Options

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


New To Site? Need Help?

All times are GMT. The time now is 19:16.

Layout Options | Width: Wide Color: