Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Image Uploads/Display (Read 3018 times)
Dave Rapp
Junior Member
**
Offline


Have a great day!!!

Posts: 89
Location: Cameron County
Joined: Aug 30th, 2002
Gender: Male
Image Uploads/Display
Mar 13th, 2009 at 1:01am
Print Post  
Hi, I'm writing a program which includes a guestbook for which I would like to make it possible for posters to upolad an image. The problem: I need a snippet, subroutine or whatever for this as I have never worked with file uploading. The things I need control of are---file size limits, file types allowed, and file renaming using the same file extension. If it makes any difference I'm using the cgi-lib.pl. The reason for file renaming: each poster will have a unique code to be associated with ther name and email address so that a person can upload a pic at a later date or change their pic--the unique file name could simply be overwritten in the case of a new pic plus it would eliminate any chance of two images having the same name ALSO--I'm looking for something so that when the pics are displayed a control to limit the display sizes such as maximum width, height so as not to cause the images to appear out of proportion. Thanx much for any help possible.
  

If you choose not to decide you still have made a choice.
Back to top
WWWYIM  
IP Logged
 
deti
Full Member
***
Offline


YaBB is the best!!!

Posts: 101
Location: Prien am Chiemsee
Joined: Mar 13th, 2008
Re: Image Uploads/Display
Reply #1 - Mar 13th, 2009 at 7:19am
Print Post  
Look into the Profile.pl and/or Post.pl there the avatar and attachments upload, size limit and renaming is done well.

For the display sizing use our resize_images JavaScript function in YaBB.js.
  

Was immer Du tun kannst
oder erträumst tun zu können,
beginne es.
Kühnheit besitzt Genie,
Macht und magische Kraft.
Beginne es jetzt.
Whatever you can do
or dream you can,
begin it.
Boldness has genius,
power and magic in it.
Begin it now.
Johann Wolfgang Goethe
Back to top
 
IP Logged
 
Dave Rapp
Junior Member
**
Offline


Have a great day!!!

Posts: 89
Location: Cameron County
Joined: Aug 30th, 2002
Gender: Male
Re: Image Uploads/Display
Reply #2 - Mar 13th, 2009 at 10:41am
Print Post  
Oh my, where do I start?? I looked through those files and got lost quick. At this point I only have the name for the file upload on the form and the name the file will be changed to. In profile.pl around line 630 I see where they begin talking about the images(couldn't find in post.pl). Can't find however, file types allowed or the errors for wrong types or about renaming them. Basically I only have the <input type="file"> so far. Also, I looked at the YaBB.js file under the image resizing and in that one possibly the variables for the sizing(but not positive on that one) I realize I'm asking alot here and apologize for that but uploads and image sizing are all new to me.  Huh
  

If you choose not to decide you still have made a choice.
Back to top
WWWYIM  
IP Logged
 
deti
Full Member
***
Offline


YaBB is the best!!!

Posts: 101
Location: Prien am Chiemsee
Joined: Mar 13th, 2008
Re: Image Uploads/Display
Reply #3 - Mar 13th, 2009 at 4:36pm
Print Post  
To begin you must use other <form tag:

Find in Post.pl
Code
Select All
		if (&AccessCheck($currentboard, 4) eq "granted" && $allowattach && ${$uid.$currentboard}{'attperms'} == 1) {
			$yymain .= qq~<form action="$scripturl?$thecurboard" method="post" name="postmodify" enctype="multipart/form-data" onsubmit="if(!checkForm(this)) {return false} else {return submitproc()}">~;
		} else { 




the input tag must look like this:
Code
Select All
<input type="file" name="fileX" /> 



Then give a look into this loop in Post.pl
I assume you want to use this within YaBB because otherwise you must know more about CGI.pm
Code
Select All
		if ($numcount < 2) { &Preview("$post_polltxt{'38'}"); }
	}

	my ($file,$fixfile,@filelist,%filesizekb);
	for (my $y = 1; $y <= $allowattach; ++$y) {
		$file = $CGI_query->upload("file$y") if $CGI_query;
		if ($file) {
			$fixfile = $file;
			$fixfile =~ s/.+\\([^\\]+)$|.+\/([^\/]+)$/$1/;

................

	}
	#Create the list of files
	$fixfile = join(",", @filelist); 



Now everything should be fine. You can store the name of the files in $fixfile and call them on your browser. Wink

Good luck!
  

Was immer Du tun kannst
oder erträumst tun zu können,
beginne es.
Kühnheit besitzt Genie,
Macht und magische Kraft.
Beginne es jetzt.
Whatever you can do
or dream you can,
begin it.
Boldness has genius,
power and magic in it.
Begin it now.
Johann Wolfgang Goethe
Back to top
 
IP Logged
 
Dave Rapp
Junior Member
**
Offline


Have a great day!!!

Posts: 89
Location: Cameron County
Joined: Aug 30th, 2002
Gender: Male
Re: Image Uploads/Display
Reply #4 - Mar 14th, 2009 at 8:52am
Print Post  
No, this isn't to be used in YaBB. Actually its part of a script for a Christian website. Anyway, I tried it to no avail. What a time to not know anything about CGI.PM. I really appreciate your time spent however--God Bless Smiley
  

If you choose not to decide you still have made a choice.
Back to top
WWWYIM  
IP Logged
 
deti
Full Member
***
Offline


YaBB is the best!!!

Posts: 101
Location: Prien am Chiemsee
Joined: Mar 13th, 2008
Re: Image Uploads/Display
Reply #5 - Mar 14th, 2009 at 4:15pm
Print Post  
Welcome!
  

Was immer Du tun kannst
oder erträumst tun zu können,
beginne es.
Kühnheit besitzt Genie,
Macht und magische Kraft.
Beginne es jetzt.
Whatever you can do
or dream you can,
begin it.
Boldness has genius,
power and magic in it.
Begin it now.
Johann Wolfgang Goethe
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint