473,756 Members | 6,098 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Http post fields ...

Hi,

I'm trying to add an simple upload applet to shopping cart script. My new
applet form sends all needed post fields ( quantity, product, etc... )
but the "file" post field is hardcoded in applet.
Shop script works with :
<input type="file" name="id[SourceFile_1]"/>
but not with applet's:
<input type="file" name="SourceFil e_1"/>
I just cannot figure out how to fix this :(
Could somebody please help me?

Thanks in advanced,

-Event

Upload function:
############### ############### ############### ############### ######

function actionUploadPho tos($goto, $parameters, $message=false) {
global $messageStack, $db;
if (isset($_POST['products_id']) && is_numeric($_PO ST['products_id'])) {
$the_list = '';
$adjust_max= 'false';
if (isset($_POST['id'])) {
foreach ($_POST['id'] as $key =$value) {
$check = zen_get_attribu tes_valid($_POS T['products_id'], $key,
$value);
if ($check == false) {
$the_list .= TEXT_ERROR_OPTI ON_FOR . '<span class="alertBla ck">'
.. zen_options_nam e($key) . '</span>' . TEXT_INVALID_SE LECTION . '<span
class="alertBla ck">' . (zen_values_nam e($value) == 'TEXT' ?
TEXT_INVALID_US ER_INPUT : zen_values_name ($value)) . '</span>' . '<br />';
}
}
}
$add_max = zen_get_product s_quantity_orde r_max($_POST['products_id']);
$cart_qty = $this->in_cart_mixed( $_POST['products_id']);
$new_qty = $_POST['cart_quantity'];
//echo 'I SEE actionUploadPho tos: ' . $_POST['products_id'] . '<br>';
$new_qty = $this->adjust_quantit y($new_qty, $_POST['products_id'],
'shopping_cart' );
if (($add_max == 1 and $cart_qty == 1)) {
// do not add
$new_qty = 0;
$adjust_max= 'true';
} else {
// adjust quantity if needed
if (($new_qty + $cart_qty $add_max) and $add_max != 0) {
$adjust_max= 'true';
$new_qty = $add_max - $cart_qty;
}
}
if ((zen_get_produ cts_quantity_or der_max($_POST['products_id']) == 1
and $this->in_cart_mixed( $_POST['products_id']) == 1)) {
} else {

if ($the_list != '') {
$messageStack->add('product_i nfo', ERROR_CORRECTIO NS_HEADING .
$the_list, 'caution');
} else {
$real_ids = isset($_POST['id']) ? $_POST['id'] : "";
if (isset($_GET['number_of_uplo ads']) &&
$_GET['number_of_uplo ads'] 0) {
/**
* Need the upload class for attribute type that allows uploads.
*
*/
include(DIR_WS_ CLASSES . 'upload2.php');
for ($i = 1, $n = $_GET['number_of_uplo ads']; $i <= $n; $i++) {
if
(zen_not_null($ _FILES['SourceFile_1']['tmp_name'][TEXT_PREFIX .
$_POST[UPLOAD_PREFIX . $i]]) and
($_FILES['SourceFile_1']['tmp_name'][TEXT_PREFIX . $_POST[UPLOAD_PREFIX .
$i]] != 'none')) {
$products_optio ns_file = new upload('id');
$products_optio ns_file->set_destinatio n(DIR_FS_UPLOAD S);
$products_optio ns_file->set_output_mes sages('session' );
if ($products_opti ons_file->parse(TEXT_PRE FIX .
$_POST[UPLOAD_PREFIX . $i])) {
$products_image _extension =
substr($product s_options_file->filename,
strrpos($produc ts_options_file->filename, '.'));

if ($_SESSION['customer_id']) {
$db->Execute("inser t into " . TABLE_FILES_UPL OADED . "
(sesskey, customers_id, files_uploaded_ name) values('" . zen_session_id( ) .
"', '" . $_SESSION['customer_id'] . "', '" .
zen_db_input($p roducts_options _file->filename) . "')");
} else {
$db->Execute("inser t into " . TABLE_FILES_UPL OADED . "
(sesskey, files_uploaded_ name) values('" . zen_session_id( ) . "', '" .
zen_db_input($p roducts_options _file->filename) . "')");
}
$insert_id = $db->Insert_ID();
$real_ids[TEXT_PREFIX . $_POST[UPLOAD_PREFIX . $i]] =
$insert_id . ". " . $products_optio ns_file->filename;
$products_optio ns_file->set_filename(" $insert_id" .
$products_image _extension);
if (!($products_op tions_file->save())) {
break;
}
} else {
break;
}
} else { // No file uploaded -- use previous value
$real_ids[TEXT_PREFIX . $_POST[UPLOAD_PREFIX . $i]] =
$_POST[TEXT_PREFIX . UPLOAD_PREFIX . $i];
}
}
}

$this->add_cart($_POS T['products_id'],
$this->get_quantity(z en_get_uprid($_ POST['products_id'],
$real_ids))+($n ew_qty), $real_ids);
// iii 030813 end of changes.
} // eof: set error message
} // eof: quantity maximum = 1

if ($adjust_max == 'true') {
$messageStack->add_session('s hopping_cart', ERROR_MAXIMUM_Q TY . '
B: - ' . zen_get_product s_name($_POST['products_id']), 'caution');
}
}
if ($the_list == '') {
if (DISPLAY_CART == 'false' && $_GET['main_page'] !=
FILENAME_SHOPPI NG_CART) {
$messageStack->add_session('h eader', SUCCESS_ADDED_T O_CART_PRODUCT,
'success');
}
zen_redirect(ze n_href_link($go to,
zen_get_all_get _params($parame ters)));
} else {
}
}

############### ############### ############### ############### ############### ############### ##########
in upload2.php ( parse function and save )

function parse($key = '') {
global $messageStack;

if (isset($_FILES[$this->file])) {
if (zen_not_null($ key)) {
$file = array('name' =$_FILES[$this->file]['name'][$key],
'type' =$_FILES[$this->file]['type'][$key],
'size' =$_FILES[$this->file]['size'][$key],
'tmp_name' =$_FILES['file']['tmp_name']);
} else {
$file = array('name' =$_FILES[$this->file]['name'],
'type' =$_FILES[$this->file]['type'],
'size' =$_FILES[$this->file]['size'],
'tmp_name' =$_FILES['file']['tmp_name']);
}
} elseif (isset($GLOBALS['HTTP_POST_FILE S'][$this->file])) {
global $HTTP_POST_FILE S;

$file = array('name' =$HTTP_POST_FIL ES[$this->file]['name'],
'type' =$HTTP_POST_FIL ES[$this->file]['type'],
'size' =$HTTP_POST_FIL ES[$this->file]['size'],
'tmp_name' =$HTTP_POST_FIL ES[$this->file]['tmp_name']);
} else {
$file = array('name' =(isset($GLOBAL S[$this->file . '_name']) ?
$GLOBALS[$this->file . '_name'] : ''),
'type' =(isset($GLOBAL S[$this->file . '_type']) ?
$GLOBALS[$this->file . '_type'] : ''),
'size' =(isset($GLOBAL S[$this->file . '_size']) ?
$GLOBALS[$this->file . '_size'] : ''),
'tmp_name' =(isset($GLOBAL S[$this->file]) ? $GLOBALS[$this->file] :
''));
}
if (!is_uploaded_f ile($_FILES['tmp_name'])) {
if ($this->message_locati on == 'direct') {
$messageStack->add_session('h eader', WARNING_NO_FILE _UPLOADED,
'warning');
} else {
$messageStack->add_session('u pload', WARNING_NO_FILE _UPLOADED,
'warning');
}
return false;
}

if ( zen_not_null($f ile['tmp_name']) && ($file['tmp_name'] != 'none') &&
is_uploaded_fil e($file['tmp_name']) ) {
if (zen_not_null($ file['size']) and ($file['size'] >
MAX_FILE_UPLOAD _SIZE)) {
if ($this->message_locati on == 'direct') {
$messageStack->add_session('h eader', ERROR_FILE_TOO_ BIG, 'error');
} else {
$messageStack->add_session('u pload', ERROR_FILE_TOO_ BIG, 'error');
}
return false;
}

if (sizeof($this->extensions) 0) {
if (!in_array(strt olower(substr($ file['name'],
strrpos($file['name'], '.')+1)), $this->extensions)) {
if ($this->message_locati on == 'direct') {
$messageStack->add_session('h eader', ERROR_FILETYPE_ NOT_ALLOWED
.. ' ' . UPLOAD_FILENAME _EXTENSIONS, 'error');
} else {
$messageStack->add_session('u pload', ERROR_FILETYPE_ NOT_ALLOWED
.. ' - ' . UPLOAD_FILENAME _EXTENSIONS, 'error');
}
return false;
}
}

$this->set_file($file );
$this->set_filename($ file['name']);
$this->set_tmp_filena me($file['tmp_name']);

return $this->check_destinat ion();
} else {
if ($this->message_locati on == 'direct') {
$messageStack->add_session('h eader', WARNING_NO_FILE _UPLOADED,
'warning');
} else {
$messageStack->add_session('u pload', WARNING_NO_FILE _UPLOADED,
'warning');
}
return false;
}
}
function save() {
global $messageStack;

if (substr($this->destination, -1) != '/') $this->destination .= '/';

if (move_uploaded_ file($this->file['tmp_name'], $this->destination .
$this->filename)) {
$width = 100;
$height = 100;
list($width_ori g, $height_orig) = getimagesize($t his->destination .
$this->filename);

if ($width && ($width_orig < $height_orig)) {
$width = ($height / $height_orig) * $width_orig;
} else {
$height = ($width / $width_orig) * $height_orig;
}
// Resample
$image_p = imagecreatetrue color($width, $height);
$image = imagecreatefrom jpeg($this->destination . $this->filename);
imagecopyresamp led($image_p, $image, 0, 0, 0, 0, $width, $height,
$width_orig, $height_orig);
imagejpeg($imag e_p, $this->destination . '/th/'. $this->filename,
100);
chmod($this->destination . '/th/'. $this->filename,
$this->permissions) ;
if ($this->message_locati on == 'direct') {
$messageStack->add_session('h eader',
SUCCESS_FILE_SA VED_SUCCESSFULL Y, 'success');
} else {
$messageStack->add_session('u pload',
SUCCESS_FILE_SA VED_SUCCESSFULL Y, 'success');
}

return true;
} else {
if ($this->message_locati on == 'direct') {
$messageStack->add_session('h eader', ERROR_FILE_NOT_ SAVED, 'error');
} else {
$messageStack->add_session('u pload', ERROR_FILE_NOT_ SAVED, 'error');
}

return false;
}
}

function set_file($file) {
$this->file = $file;
}

function set_destination ($destination) {
$this->destination = $destination;
}

function set_permissions ($permissions) {
$this->permissions = octdec($permiss ions);
}

function set_filename($f ilename) {
$this->filename = $filename;
}

function set_tmp_filenam e($filename) {
$this->tmp_filename = $filename;
}

function set_extensions( $extensions) {
if (zen_not_null($ extensions)) {
if (is_array($exte nsions)) {
$this->extensions = $extensions;
} else {
$this->extensions = array($extensio ns);
}
} else {
$this->extensions = array();
}
}

function check_destinati on() {
global $messageStack;

if (!is_writeable( $this->destination) ) {
if (is_dir($this->destination) ) {
if ($this->message_locati on == 'direct') {
$messageStack->add_session('h eader',
sprintf(ERROR_D ESTINATION_NOT_ WRITEABLE, $this->destination) , 'error');
} else {
$messageStack->add_session('u pload',
sprintf(ERROR_D ESTINATION_NOT_ WRITEABLE, $this->destination) , 'error');
}
} else {
if ($this->message_locati on == 'direct') {
$messageStack->add_session('h eader',
sprintf(ERROR_D ESTINATION_DOES _NOT_EXIST, $this->destination) , 'error');
} else {
$messageStack->add_session('u pload',
sprintf(ERROR_D ESTINATION_DOES _NOT_EXIST, $this->destination) , 'error');
}
}

return false;
} else {
return true;
}
}

function set_output_mess ages($location) {
switch ($location) {
case 'session':
$this->message_locati on = 'session';
break;
case 'direct':
default:
$this->message_locati on = 'direct';
break;
}
}
}


Jun 23 '07 #1
0 1671

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2465
by: Spud | last post by:
<?php // pullpage function by Nick bouton http://www.nickbouton.com/. $CustomerID = "IDHERE"; $method = "POST"; $host = "xml.mydata.com"; $usepath = "/xml.asp"; //print all vars in an array
3
2516
by: Robert | last post by:
Hello, Can anyone help with this? On my online order form, I need to send a few variables to my credit-card processor. These variables are for non-secure customer comments, and will be sent through the usual metod, i.e., <form action="https://orderpage.ic3.com/hop/orderform.jsp" method="post">
8
1828
by: bmgx | last post by:
I would like to use an already existing online service (currency converter) basically consisting of a html form with a few options that is submitted and returns the results. I really don't know where to start but I have assumed the following steps need to be taken: 1) Make an http connection to the remote script (http://server/script.cgi) 2) Fill out the html form (1x TEXT and 2x SELECT input fields) 3) Submit the form
5
5379
by: Nelson Minar | last post by:
I'm writing some code to upload photos to Flickr. The Photo Upload API requires documents be POSTed via a multipart/form-data request. I was surprised to learn that Python 2.3's HTTP clients don't support this form of POSTs. There is support in cgi.py, for servers. There are some implementations of multipart/form-data on ASPN: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/146306 urllib2_file seems to meet my needs, but I'm not...
2
1791
by: vm | last post by:
Hi, for some reason my POST is not working properly. I am basically just trying to get a simple stock quote from yahoo by posting the ticker symbol (GE as an example) into finance.yahoo.com. However, when I POST, I do get a response back, but it is just the main page finance.yahoo.com and it doesn't seem as if the POST got through. I am using Python 2.2. I get a status and reason of 200 and OK respectively. I've searched through these...
3
2524
by: Tim Wade | last post by:
Does anyone have any ideas on how to do an automatic html form post using hidden fields without introducing client-side script nor using a server-side WebRequest by passing the information back up to the browser while the base href is still set to my site. The problem I was having with the server-side WebRequest is that the relative links of the site I am posting to break. I could work my way around it probably by adding a base ref in the...
2
1981
by: Mike | last post by:
I need to POST some hidden fields to a page, which i need to load in the browser window.. i've tryed writting out the hidden fields and doing a response.redirect/response.transfer but these don't send accross the hidden fields.... so my question really is how do i send hidden fields and transfer to a page (where they can be picked up from)? Thanks a million in advance
10
3439
by: glenn | last post by:
I am use to programming in php and the way session and post vars are past from fields on one page through to the post page automatically where I can get to their values easily to write to a database or continue to process on to the next page. I am now trying to learn ASP to see if we can replace some of our applications that were written in php with an ASP alternative. However, after doing many searches on google and reading a couple...
24
2882
by: moriman | last post by:
Hi, The script below *used* to work. I have only just set up a server, PHP etc again on my Win98 system and now it doesn't? On first loading this page, you would have $p = and the button image below it.
1
3703
by: ERobishaw | last post by:
Using Winform app writing a HTTP Post using the following... on the server side, I get no form fields. Request.Form.AllKeys.Length = 0. If I put the field/value paris in the URL I can use Request to retrieve the values, but POST doesn't work. There is NO Proxy... the only thing I can think is that ASP.NET is somehow filtering out the page because I'm obviously not posting the viewstate??? Seems like there was some setting for this,...
0
9454
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9271
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9836
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8709
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7242
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6533
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5139
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2664
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.