Ask a Question related to Dreamweaver AppDev, Design and Development.
-
bethan81 #1
stupid picture uploading using PHP
I have been trying to upload a file to a folder on the server, and display the
filename in the database, so that i can link to this file and display it. The
code i have works in one example, but not in the one that i am currently
working with and i have no idea why. I have ammended it correctly, but it still
doesnt work, can any body help? p.s. i think its the upload bit is at the end,
but am not entirely sure.
any help would be great.
Here is my code:
<?php require_once('Connections/mysql.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "",
$theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" :
"NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
}
if ((isset($HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"] ==
"form1")) {
$insertSQL = sprintf("INSERT INTO artistmembers (email, membernameid,
membername, memberpicture, membertext, memberposition) VALUES (%s, %s, %s, %s,
%s, %s)",
GetSQLValueString($HTTP_POST_VARS['email'], "text"),
GetSQLValueString($HTTP_POST_VARS['membernameid'],
"int"),
GetSQLValueString($HTTP_POST_VARS['membername'],
"text"),
GetSQLValueString($_FILES['memberpicture']['name'], "text"),
GetSQLValueString($HTTP_POST_VARS['membertext'],
"text"),
GetSQLValueString($HTTP_POST_VARS['memberposition'],
"text"));
mysql_select_db($database_mysql, $mysql);
$Result1 = mysql_query($insertSQL, $mysql) or die(mysql_error());
}
mysql_select_db($database_mysql, $mysql);
$query_loadmember = "SELECT * FROM artistmembers";
$loadmember = mysql_query($query_loadmember, $mysql) or die(mysql_error());
$row_loadmember = mysql_fetch_assoc($loadmember);
$totalRows_loadmember = mysql_num_rows($loadmember);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- DW6 -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- TemplateBeginEditable name="doctitle" -->
<title>Untitled Document</title>
<!-- TemplateEndEditable --><link rel="stylesheet" href="3col_leftNav.css"
type="text/css">
<style type="text/css">
<!--
.style1 {color: #FFFFFF}
.style8 {font-size: 10px}
.style9 {font-size: 12px}
-->
</style>
<!-- TemplateParam name="Headline1" type="boolean" value="true" -->
<!-- TemplateBeginEditable name="head" --><!-- TemplateEndEditable -->
</head>
<body>
<div id="masthead">
<h1 id="siteName">Soundstage</h1>
<div id="globalNav">
<a href="register.html">register</a> | <a href="login.html">login</a> | <a
href="logout.html">logout</a> | <a href="#">basket</a> |
<a href="#">checkout</a> |
</div>
<h2 class="style1" id="pageName">reviews...</h2>
<div id="breadCrumb">
<a href="#">breadcrumb</a> / <a href="#">breadcrumb</a> / <a
href="#">breadcrumb</a> /
</div>
</div>
<div id="navBar">
<div id="search">
<form action="#">
<label>search</label>
<input name="searchFor" type="text" size="10">
<input name="goButton" type="submit" value="go">
</form>
</div>
<div id="sectionLinks">
<h3>Section Links</h3>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="artists.html">Artists</a></li>
<li><a href="genre.html">Genre</a></li>
<li><a href="city.html">City</a></li>
<li><a href="reviews.html">Reviews</a></li>
<li><a href="#">Section Link</a></li>
</ul>
</div>
<div class="relatedLinks">
<h3>Related Link Category</h3>
<ul>
<li><a href="#">Related Link</a></li>
<li><a href="#">Related Link</a></li>
<li><a href="#">Related Link</a></li>
<li><a href="#">Related Link</a></li>
<li><a href="#">Related Link</a></li>
<li><a href="#">Related Link</a></li>
</ul>
</div>
<div class="relatedLinks">
<h3>Related Link Category</h3>
<ul>
<li><a href="#">Related Link</a></li>
<li><a href="#">Related Link</a></li>
<li><a href="#">Related Link</a></li>
<li><a href="#">Related Link</a></li>
<li><a href="#">Related Link</a></li>
<li><a href="#">Related Link</a></li>
</ul>
</div>
</div>
<!--end navBar div -->
<div id="headlines">
<h3>Artist of the week:</h3>
<p>
</p>
<div id="advert">
<img src="" alt="" width="107" height="66"> Ad copy ad copy ad copy. Ad
copy ad copy.
</div>
</div>
<!--end headlines -->
<div id="content"> </div>
<!--end content -->
<table width="53%" height="34" border="0">
<tr>
<td><a href="bandsection1.php"></a>
<p align="center"><a href="bandsection1.php">back to edit
band</a></p></td>
</tr>
</table>
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">Membername:</td>
<td><input type="text" name="membername" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Memberpicture:</td>
<td><input type="file" name="memberpicture" value="uploadfile"
size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right" valign="top">Membertext:</td>
<td> <textarea name="membertext" cols="50" rows="5"></textarea> </td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Memberposition:</td>
<td><input type="text" name="memberposition" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td><input name="submit" type="submit" value="Insert Record"></td>
</tr>
</table>
<input type="hidden" name="email" value="">
<input type="hidden" name="membernameid" value="">
<input type="hidden" name="MM_insert" value="form1">
</form>
<p> </p>
<div align="left">
<p> </p>
</div>
<div id="siteInfo">
<img src="" width="44" height="22"> <a href="#">About Us</a> | <a
href="#">Site
Map</a> | <a href="#">Privacy Policy</a> | <a href="#">Contact Us</a> |
©2003
Company Name
</div>
<br>
<p> </p>
</body>
</html>
<?
echo $HTTP_POST_VARS['memberpicture'];
$uploaddir = '//ftpserver/www/bla/bla/bla/bla/';
$uploadfile = $uploaddir . basename($_FILES['memberpicture']['name']);
echo $uploadfile;
echo '<pre>';
if (move_uploaded_file($_FILES['memberpicture']['tmp_name'], $uploadfile)) {
echo "Your a mastermind.....\n";
}
else {
echo "Possible file upload attack!\n";
}
echo 'Here is some more debugging info:';
print_r($_FILES);
print "</pre>";
?>
<?php
mysql_free_result($loadmember);
?>
bethan81 Guest
-
Help! Did something stupid with CF Administrator
I've been trying to use a FileMaker Pro database as a datasource using a local CF test server (I'm on Mac OS X so I don't have Access but have FM... -
Stupid Mistake
I am using CFMX 6.1 and I was playing with the settings in Sandbox Security and now I cannot get access to CF Admin. I get the following error: ... -
Im really stupid so please help me
how do i make a loading animation for my site and make it appear when i a page is loading? -
Stupid C# question Please help!
I'm used to writing my code in VBscript but I have to do this project in C#. I've written some functions on my ASP.Net page and I'm getting an... -
Stupid dreamweaver
Does anyone have the same problem with rollovers as I have? When you put buttons on a page and attach the behaviors, the rollovers stay open, or they... -
Alexandro Colorado #2
Re: stupid picture uploading using PHP
On Thu, 3 Mar 2005 01:25:27 +0000 (UTC), bethan81
<webforumsuser@macromedia.com> wrote:
We currently have an extension that does this work for you. We have had> I have been trying to upload a file to a folder on the server, and
> display the
> filename in the database, so that i can link to this file and display
> it. The
> code i have works in one example, but not in the one that i am currently
> working with and i have no idea why. I have ammended it correctly, but
> it still
> doesnt work, can any body help? p.s. i think its the upload bit is at
> the end,
> but am not entirely sure.
> any help would be great.
>
> Here is my code:
> <?php require_once('Connections/mysql.php'); ?>
> <?php
> function GetSQLValueString($theValue, $theType, $theDefinedValue = "",
> $theNotDefinedValue = "")
> {
> $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) :
> $theValue;
>
> switch ($theType) {
> case "text":
> $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
> break;
> case "long":
> case "int":
> $theValue = ($theValue != "") ? intval($theValue) : "NULL";
> break;
> case "double":
> $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" :
> "NULL";
> break;
> case "date":
> $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
> break;
> case "defined":
> $theValue = ($theValue != "") ? $theDefinedValue :
> $theNotDefinedValue;
> break;
> }
> return $theValue;
> }
>
> $editFormAction = $HTTP_SERVER_VARS['PHP_SELF'];
> if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
> $editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
> }
>
> if ((isset($HTTP_POST_VARS["MM_insert"])) &&
> ($HTTP_POST_VARS["MM_insert"] ==
> "form1")) {
> $insertSQL = sprintf("INSERT INTO artistmembers (email, membernameid,
> membername, memberpicture, membertext, memberposition) VALUES (%s, %s,
> %s, %s,
> %s, %s)",
> GetSQLValueString($HTTP_POST_VARS['email'],
> "text"),
> GetSQLValueString($HTTP_POST_VARS['membernameid'],
> "int"),
> GetSQLValueString($HTTP_POST_VARS['membername'],
> "text"),
> GetSQLValueString($_FILES['memberpicture']['name'], "text"),
> GetSQLValueString($HTTP_POST_VARS['membertext'],
> "text"),
> GetSQLValueString($HTTP_POST_VARS['memberposition'],
> "text"));
>
> mysql_select_db($database_mysql, $mysql);
> $Result1 = mysql_query($insertSQL, $mysql) or die(mysql_error());
> }
>
> mysql_select_db($database_mysql, $mysql);
> $query_loadmember = "SELECT * FROM artistmembers";
> $loadmember = mysql_query($query_loadmember, $mysql) or
> die(mysql_error());
> $row_loadmember = mysql_fetch_assoc($loadmember);
> $totalRows_loadmember = mysql_num_rows($loadmember);
> ?>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> "http://www.w3.org/TR/html4/loose.dtd">
> <html>
> <!-- DW6 -->
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
> <!-- TemplateBeginEditable name="doctitle" -->
> <title>Untitled Document</title>
> <!-- TemplateEndEditable --><link rel="stylesheet"
> href="3col_leftNav.css"
> type="text/css">
> <style type="text/css">
> <!--
> .style1 {color: #FFFFFF}
> .style8 {font-size: 10px}
> .style9 {font-size: 12px}
> -->
> </style>
> <!-- TemplateParam name="Headline1" type="boolean" value="true" -->
> <!-- TemplateBeginEditable name="head" --><!-- TemplateEndEditable -->
> </head>
> <body>
> <div id="masthead">
> <h1 id="siteName">Soundstage</h1>
> <div id="globalNav">
> <a href="register.html">register</a> | <a
> href="login.html">login</a> | <a
> href="logout.html">logout</a> | <a href="#">basket</a> |
> <a href="#">checkout</a> |
> </div>
> <h2 class="style1" id="pageName">reviews...</h2>
> <div id="breadCrumb">
> <a href="#">breadcrumb</a> / <a href="#">breadcrumb</a> / <a
> href="#">breadcrumb</a> /
> </div>
> </div>
> <div id="navBar">
> <div id="search">
> <form action="#">
> <label>search</label>
> <input name="searchFor" type="text" size="10">
> <input name="goButton" type="submit" value="go">
> </form>
> </div>
> <div id="sectionLinks">
> <h3>Section Links</h3>
> <ul>
> <li><a href="index.html">Home</a></li>
> <li><a href="artists.html">Artists</a></li>
> <li><a href="genre.html">Genre</a></li>
> <li><a href="city.html">City</a></li>
> <li><a href="reviews.html">Reviews</a></li>
> <li><a href="#">Section Link</a></li>
> </ul>
> </div>
> <div class="relatedLinks">
> <h3>Related Link Category</h3>
> <ul>
> <li><a href="#">Related Link</a></li>
> <li><a href="#">Related Link</a></li>
> <li><a href="#">Related Link</a></li>
> <li><a href="#">Related Link</a></li>
> <li><a href="#">Related Link</a></li>
> <li><a href="#">Related Link</a></li>
> </ul>
> </div>
> <div class="relatedLinks">
> <h3>Related Link Category</h3>
> <ul>
> <li><a href="#">Related Link</a></li>
> <li><a href="#">Related Link</a></li>
> <li><a href="#">Related Link</a></li>
> <li><a href="#">Related Link</a></li>
> <li><a href="#">Related Link</a></li>
> <li><a href="#">Related Link</a></li>
> </ul>
> </div>
> </div>
> <!--end navBar div -->
> <div id="headlines">
> <h3>Artist of the week:</h3>
> <p>
> </p>
> <div id="advert">
> <img src="" alt="" width="107" height="66"> Ad copy ad copy ad
> copy. Ad
> copy ad copy.
> </div>
> </div>
> <!--end headlines -->
> <div id="content"> </div>
> <!--end content -->
> <table width="53%" height="34" border="0">
> <tr>
> <td><a href="bandsection1.php"></a>
> <p align="center"><a href="bandsection1.php">back to edit
> band</a></p></td>
> </tr>
> </table>
> <form method="post" name="form1" action="<?php echo $editFormAction;
> ?>">
> <table align="center">
> <tr valign="baseline">
> <td nowrap align="right">Membername:</td>
> <td><input type="text" name="membername" value="" size="32"></td>
> </tr>
> <tr valign="baseline">
> <td nowrap align="right">Memberpicture:</td>
> <td><input type="file" name="memberpicture" value="uploadfile"
> size="32"></td>
> </tr>
> <tr valign="baseline">
> <td nowrap align="right" valign="top">Membertext:</td>
> <td> <textarea name="membertext" cols="50" rows="5"></textarea>
> </td>
> </tr>
> <tr valign="baseline">
> <td nowrap align="right">Memberposition:</td>
> <td><input type="text" name="memberposition" value=""
> size="32"></td>
> </tr>
> <tr valign="baseline">
> <td nowrap align="right"> </td>
> <td><input name="submit" type="submit" value="Insert Record"></td>
> </tr>
> </table>
> <input type="hidden" name="email" value="">
> <input type="hidden" name="membernameid" value="">
> <input type="hidden" name="MM_insert" value="form1">
> </form>
> <p> </p>
> <div align="left">
> <p> </p>
> </div>
> <div id="siteInfo">
> <img src="" width="44" height="22"> <a href="#">About Us</a> | <a
> href="#">Site
> Map</a> | <a href="#">Privacy Policy</a> | <a href="#">Contact Us</a>
> |
> ©2003
> Company Name
> </div>
> <br>
> <p> </p>
> </body>
> </html>
> <?
> echo $HTTP_POST_VARS['memberpicture'];
> $uploaddir = '//ftpserver/www/bla/bla/bla/bla/';
> $uploadfile = $uploaddir . basename($_FILES['memberpicture']['name']);
> echo $uploadfile;
>
> echo '<pre>';
> if (move_uploaded_file($_FILES['memberpicture']['tmp_name'],
> $uploadfile)) {
> echo "Your a mastermind.....\n";
> }
> else {
> echo "Possible file upload attack!\n";
> }
>
> echo 'Here is some more debugging info:';
> print_r($_FILES);
> print "</pre>";
>
> ?>
> <?php
> mysql_free_result($loadmember);
> ?>
>
great result generating upload engine on secure way specially when
dealing with PHP
You might want to check our extension here:
[url]http://www.interaktonline.com/Products/Dreamweaver-Extensions/ImpAKT/Overview/[/url]
--
Alexandro Colorado
------------------------------
Support Engineer
InterAKT Online
[url]http://www.interaktonline.com[/url]
Tel: 40(21) 312.5312
Alexandro Colorado Guest
-
bethan81 #3
Re: stupid picture uploading using PHP
hi, that would be useful if i could install it, i am currently using the university macromedia mx software, and it would be impossible to upgrade the extension. Thanks anyway.
bethan81 Guest
-
Felix1 #4
Re: stupid picture uploading using PHP
You miss the enctype='multipart/form-data' inside the form tag.
Felix
[email]webmaster@felixone.it[/email]
[url]http://www.felixone.it[/url]
Felix1 Guest
-
bethan81 #5
Re: stupid picture uploading using PHP
hi thanks so much for your help, sorry about the messy code!!!!!!!
bethan81 Guest



Reply With Quote

