Toon posts:

php

Pagina: 1
Acties:
  • 43 views sinds 30-01-2008

Verwijderd

Topicstarter
Hallo, ik ben bezig met het maken van een upload script. Alles doet het goed. Maar op 1 of andere manier geeft die het path van mijn upload voor de foto's niet mee.

Wie kan me helpen ?


<?php
include "database/webconfig.php";
require "class/upload_class.php";

if ($_SERVER['REQUEST_METHOD'] == "POST") {
$_upload = new upload($_FILES["picture"]["name"],$_FILES["picture"]["tmp_name"],"uploads/");
$_upload->check_filesize($_FILES["picture"]["size"]);
$_upload->check_extension("jpg jpeg gif");
$_upload->check_double("1");
if ($_upload->do_upload())
print "File uploaded :-)";
else
print "Uploading failed";
}
else {
?>

<form action="<?php echo $PHP_SELF; ?>" method="post" enctype="multipart/form-data" name="form" id="form">
<table width="510" border="0">

<tr>
<td>Nomme:</td>
<td><input name="name" type="text" id="name"></td>
</tr>
<tr>
<td>Adresse:</td>
<td><input name="adres" type="text" id="adres"></td>
</tr>
<tr>
<td>CP:</td>
<td><input name="zipcode" type="text" id="zipcode"></td>
</tr>
<tr>
<td>Ville:</td>
<td><input name="city" type="text" id="city"></td>
</tr>
<tr>
<td>Nomme bebe:</td>
<td><input name="baby" type="text" id="baby"></td>
</tr>
<tr>
<td>Date de naissance:</td>
<td><select name="day" id="day">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option>14</option>
<option>15</option>
<option>16</option>
<option>17</option>
<option>18</option>
<option>19</option>
<option>20</option>
<option>21</option>
<option>22</option>
<option>23</option>
<option>24</option>
<option>25</option>
<option>26</option>
<option>27</option>
<option>28</option>
<option>29</option>
<option>30</option>
<option>31</option>
</select>
<select name="month" id="month">
<option>janvier</option>
<option>février</option>
<option>mars</option>
<option>avril</option>
<option>mai</option>
<option>juin</option>
<option>juillet</option>
<option>août</option>
<option>septembre</option>
<option>octobre</option>
<option>novembre</option>
<option>décembre</option>
</select>
<select name="year" id="year">
<option>2000</option>
<option>2001</option>
<option>2002</option>
<option>2003</option>
<option>2004</option>
<option>2005</option>
<option>2006</option>
</select></td>
</tr>
<tr>
<td>Description de photo:</td>
<td><input name="description" type="text" id="description"></td>
</tr>
<tr>
<td>E-mail:</td>
<td><input name="email" type="text" id="email"></td>
</tr>
<tr>
<td>Photo upload</td>
<td><input name="picture" type="file" id="picture">

</tr>
<tr>
<td> </td>
<td><input name="uploaden" type="submit" id="uploaden" value="Submit"></td>
</tr>
</table>
</form>
<?php
}

if (true) {

if(trim($_POST['name']) <> "" && trim($_POST['adres']) <> "" && trim($_POST['zipcode']) <> "" && trim($_POST['city']) <> "" && trim($_POST['baby']) <> "" && trim($_POST['day']) <> "" && trim($_POST['month']) <> "" && trim($_POST['year']) <> "" && trim($_POST['description']) <> "" && trim($_POST['email']) <> "" ) {

$name = $_POST['name'];
$adres = $_POST['adres'];
$zipcode = $_POST['zipcode'];
$city = $_POST['city'];
$baby = $_POST['baby'];
$day = $_POST['day'];
$month = $_POST['month'];
$year = $_POST['year'];
$description = $_POST['description'];
$email = $_POST['email'];
$picture = $_POST['picture'];

mysql_query

("INSERT INTO personal

(name,
adres,
zipcode,
city,
baby,
day,
month,
year,
description,
email,
picture)


VALUES
('".$name."',
'".$adres."',
'".$zipcode."',
'".$city."',
'".$baby."',
'".$day."',
'".$month."',
'".$year."',
'".$description."',
'".$email."',
'".$picture."')") or die(mysql_error());

mysql_close();

}

}
?>

Dit is mijn upload class

<?php
class upload {
var $tmp;
var $path;
var $name;
var $error="";
var $mode;
var $max_size=1024;
var $ext="jpg jpeg gif";
var $file;
var $file_ext;

function upload ($name="",$name_tmp="",$path="") {
if (empty($path))
$this->error .= "<li>The script can't work with an empty path.</li>\n";
if (empty($name) || empty($name_tmp))
$this->error .= "<li>Please select a file to upload</li>\n";
$this->tmp = $name_tmp;
$this->path = $path;
$this->name = $name;
}

function check_extension ($ext="") {
if (!empty($ext))
$this->ext = $ext;
$name = explode(".",$this->name);
$total = count($name)-1; // an array starts with 0 not 1!
$this->file_ext = strtolower($name[$total]);
$this->file = ereg_replace("[^a-z0-9._]", "", str_replace(" ", "_", str_replace("%20", "_", strtolower($this->name)))); // cleanup the file
$this->file = str_replace(".".$this->file_ext,"",$this->file); // get the name without the extension
unset($total);

$ext_perm = explode(" ",$this->ext);
$valid_ext = 0;
$total = count($ext_perm);
for ($i=0; $i<$total; $i++) {
if ($this->file_ext == $ext_perm[$i]) {
$valid_ext = 1;
break;
}
}
if ($valid_ext == 0)
$this->error .= "<li>Only the following extensions will be accepted: ".$this->ext."</li>\n";
}

function check_double($mode="0") {
$this->mode = $mode;
switch ($this->mode) {
case "0": // Stop
if (file_exists($this->path.$this->file.".".$this->file_ext))
$this->error .= "<li>The filename already exists. Please rename your file.</li>\n";
$this->path = $this->path.$this->file.".".$this->file_ext;
break;
case "1": // Rename
$copy = "";
$i = 1;
while (file_exists($this->path.$this->file.$copy.".".$this->file_ext)) {
$copy = "_copy_".$i;
$i++;
}
$this->path = $this->path.$this->file.$copy.".".$this->file_ext;
break;
case "2": // Overwrite
$this->path = $this->path.$this->file.".".$this->file_ext;
break;
default:
$this->error .= "<li>The config of the upload script contains an error. Please contact the webmaster.</li>\n";
break;
}
}

function check_filesize ($file_size,$max_size="") {
if (!empty($max_size))
$this->max_size = $max_size;
$this->max_size = $this->max_size*1024;
if ($file_size >= $this->max_size)
$this->error .= "<li>The filesize (".round($file_size/1024)." kb) of your file is to big. The maximum size is: ".round($this->max_size/1024)." kb.</li>\n";
}

function do_upload () {
if (!empty($this->error)) {
print $this->error;
exit();
}
if (!@move_uploaded_file($this->tmp,$this->path)) {
@unlink($this->tmp);
return false;
}
if ($this->file_ext != "exe")
@chmod ($this->path, 0777);
return true;
}
}
?>

[ Voor 27% gewijzigd door Verwijderd op 13-07-2006 15:45 ]


  • Demo
  • Registratie: Juni 2000
  • Laatst online: 10:41

Demo

Probleemschietende Tovenaar

Help jezelf én de overige forumgebruikers eerst eens door [php]-tags te gebruiken :X Een topictitel die meer over het probleem vertelt dan alleen de gebruikte scripttaal zou ook handig zijn en volgens mij hoort het topic ook niet in dit subforum (PHP is serverside en niet clientside) maar dat weet ik niet zeker.

Modbreak:Algemene gedragsregels (Netiquette) #reageren
Reageer ontopic of reageer niet :Y)

[ Voor 15% gewijzigd door BtM909 op 13-07-2006 16:00 ]

Unix doesn't prevent a user from doing stupid things, because that would necessarily prevent them from doing brilliant things.
while true ; do echo -n "bla" ; sleep 1 ; done


  • martijnve
  • Registratie: December 2004
  • Laatst online: 13-02 14:16
Een topic php noemen is niet echt duidelijk. En sinds wanneer is php clientside?

edit: en gebruik code tags dat is beter leesbaar.

Modbreak:Algemene gedragsregels (Netiquette) #reageren
Reageer ontopic of reageer niet :Y)

[ Voor 54% gewijzigd door BtM909 op 13-07-2006 16:00 ]


Verwijderd

Topicstarter
Sorry voor de titel. Maar weet iemand een oplossing ?

  • BtM909
  • Registratie: Juni 2000
  • Niet online

BtM909

Watch out Guys...

even dicht: stay around for an update ;)

Ace of Base vs Charli XCX - All That She Boom Claps (RMT) | Clean Bandit vs Galantis - I'd Rather Be You (RMT)
You've moved up on my notch-list. You have 1 notch
I have a black belt in Kung Flu.


  • BtM909
  • Registratie: Juni 2000
  • Niet online

BtM909

Watch out Guys...

Hallo sneakyshy,

ik zie dat je nog niet zo heel veel posts hebt op dit forum, dus bij deze (nogmaals) welkom! Je bent hier gekomen omdat je een PHP probleem hebt en dan zit je uiteraard in de Devschuur® goed. Elk subforum van de Devschuur® heeft het volgende topic bovenaan staan: Waar hoort mijn topic?.

Voordat je een topic opent is het wel zo netjes om even de sticky's, FAQ's en Beleid topics door te lezen- Als je bovenstaand topic ook even had doorgelezen, dan was je meteen te weten gekomen dat PHP vragen in Programming horen :)

Verder even over de inhoud van je topic:

*** Over topictitels in PRG - lezen voor topic openen!!! ***. Een titel php zegt helemaal niks over je probleem. Probeer in de toekomst je probleem ook wat beter te beschrijven in de topictitel. :)

Alle code hier neerplempen en verwachten dat men het voor je oplost door alleen een summiere beschrijving te geven, gaat ook niet werken. GoT is geen helpdesk. We willen je best op weg helpen of je probleem oplossen, mits jij duidelijk kan aangeven waar het probleem zit, relevante code geeft (en deze tussen[plain]
PHP:
1
[/] tags plaatst), aangeeft wat je zelf hebt geprobeerd om het op te lossen en waar je tegen aanloopt.

Aangezien ik al deze dingen mis in je topic, gaat deze op slot en niet met een tikje richting de buren. Nog een keer proberen met bovenstaande tips en men is al veel eerder bereid om je op weg te helpen ;)

Ace of Base vs Charli XCX - All That She Boom Claps (RMT) | Clean Bandit vs Galantis - I'd Rather Be You (RMT)
You've moved up on my notch-list. You have 1 notch
I have a black belt in Kung Flu.

Pagina: 1

Dit topic is gesloten.