28, May 2012

How would I add a photo field to the profile? - webmaster forum

 
Webdigity webmaster forums
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  PHP classes @finalwebsites.com  >  Easy PHP Upload (Moderator: Olaf)
Topic: How would I add a photo field to the profile?
« previous next »
Pages: [1] Print
Instabuck - The easy way to sell digital products online

Author Topic: How would I add a photo field to the profile?  (Read 2149 times)
I love Pokemon
*
Posts: 13
86 credits
Members referred : 0


« on: Aug 26, 2006, 12:45:21 am »

Olaf, thanks for your prompt responses and your help.

Couple of questions that might help me along with this project. Basically i'm creating a site that features profiles of individuals who are business people. When they register they should be able to upload a photo. At the same time i'd like a thumbnail to be created. Therefore your foto_upload.php comes into play since it 'extends' the upload_class.php file with that functionality. So, first questions is.... in my main profile page where they complete the profile form, I would modify it to include an image upload field probably just borrowing the code you provide in the foto_upload form code. Would I need to 'include' both files into that page? Like

include 'foto_upload.php';
include 'upload_class.php';

I'm just not 100% on how i'd integrate these into the main scripts. Thanks.
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #1 on: Aug 26, 2006, 08:25:11 am »

the upload class is already included inside the photo upload extension...

I love Pokemon
*
Posts: 13
86 credits
Members referred : 0


« Reply #2 on: Aug 26, 2006, 08:54:27 am »

Ok, then all I need is to have the one include statement for the upload_class.php file?
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #3 on: Aug 26, 2006, 10:17:30 am »

Ok, then all I need is to have the one include statement for the upload_class.php file?
no the other one Wink

I love Pokemon
*
Posts: 13
86 credits
Members referred : 0


« Reply #4 on: Aug 26, 2006, 05:48:01 pm »

Ok, so then the foto_upload.php is what I need to include.
I love Pokemon
*
Posts: 13
86 credits
Members referred : 0


« Reply #5 on: Aug 26, 2006, 08:33:32 pm »

I think I need to explain a bit more so we can get to the right answer Smiley

Your foto_upload.php is a self contained file/class which means that the script includes the form for uploading and uses PHP_SELF as the action.

I'm using a different script called 'addbiz.php' which parses all the data from a form called 'add-form.php' which is the profile form and image upload form. I need 'addbiz.php' to take the $_POST data from 'add-form.php', create the thumbnail and full size image and insert the data and image reference into a mysql database.

So, it goes like this:

complete 'add-form.php', hit Submit, action points to 'addbiz.php' which parses the data and inserts the info into mysql.

What's missing is the function for creating the thumbnail and full sized image in my 'addbiz.php' script. I have an 'include 'foto_upload.php' statement in there but there must be some code I have to also insert that determines the parameters.

Does this help to clarify what I need? Thanks.
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #6 on: Aug 27, 2006, 10:11:13 am »

remove the form from the photo upload extension and include this mofied "class" file in your personal upload form.

I love Pokemon
*
Posts: 13
86 credits
Members referred : 0


« Reply #7 on: Aug 27, 2006, 08:18:22 pm »

Ok, to be perfectly clear on this:

1) remove the upload form from the foto_upload.php file
2) save it
3) in my current form parsing script (addbiz.php) I would have: include 'foto_upload.php';

Question:

Aside from having the 'include' statement, wouldn't I need some variables and code setting the parameters of the images?

Also, these will be inserted into a mysql database assigned to a user's specific profile.
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #8 on: Aug 27, 2006, 10:50:11 pm »

I don't know what you script is but start with splitting the extesion file into two parts:

upload_extension.php
Code:
<?php
include ($_SERVER['DOCUMENT_ROOT']."/classes/upload/upload_class.php");
error_reporting(E_ALL);
ini_set("memory_limit""64M");
set_time_limit(60);

class 
Foto_upload extends file_upload {

     
/// the class code
}
?>


the_upload_form.php
Code:
<?php
include ($_SERVER['DOCUMENT_ROOT']."/path_to/photo_upload_extension/upload_extension.php");

$max_size 1024*1024// the max. size for uploading (~1MB)
define("MAX_SIZE"$max_size);
$foto_upload = new Foto_upload;

$foto_upload->upload_dir $_SERVER['DOCUMENT_ROOT']."/test_files/"// "files" is the folder for the uploaded files (you have to create these folder)
$foto_upload->foto_folder $_SERVER['DOCUMENT_ROOT']."/test_files/photo/";
$foto_upload->thumb_folder $_SERVER['DOCUMENT_ROOT']."/test_files/thumb/";
$foto_upload->extensions = array(".jpg"); // specify the allowed extension(s) here
$foto_upload->language "en";
$foto_upload->x_max_size 300;
$foto_upload->y_max_size 200;
$foto_upload->x_max_thumb_size 120;
$foto_upload->y_max_thumb_size 150;

if (isset(
$_POST['Submit']) && $_POST['Submit'] == "Upload") {
$foto_upload->the_temp_file $_FILES['upload']['tmp_name'];
$foto_upload->the_file $_FILES['upload']['name'];
$foto_upload->http_error $_FILES['upload']['error'];
$foto_upload->replace = (isset($_POST['replace'])) ? $_POST['replace'] : "n"// because only a checked checkboxes is true
$foto_upload->do_filename_check "n"
if ($foto_upload->upload()) {
$foto_upload->process_image(falsetruetrue80);
$foto_upload->message[] = "Processed foto: ".$foto_upload->file_copy."!"// "file_copy is the name of the foto"
}
}
$error $foto_upload->show_error_string();
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Photo-upload form</title>


</head>
<body>

place here the upload form

</body>
</html>

Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=3823
Tags : html mysql databases Bookmark this thread : Digg Del.icio.us Dzone more....

Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  PHP classes @finalwebsites.com  >  Easy PHP Upload (Moderator: Olaf)
Topic: How would I add a photo field to the profile?
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 28, 2012, 03:26:11 pm





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!






Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2012 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.