upload system

Post all your tuts or request for tuts here.
User avatar
ier
Posts: 67
Joined: Sun Jan 10, 2010 7:32 pm

upload system

Post by ier »

guys I have one question kan you see what my foult is?
index.php

Code: Select all

<html>
<h1>Upload a file...</h1>
<form action='upload.php' method='POST' enctype='multipart/form-date'>
      <input type='file' name='myfile'><p>
      <input type='submit' value='Upload>
</form>

</html>
uploaded.php

Code: Select all

<?php
$name = $_FILES["myfile"]["name"];
$type = $_FILES["myfile"]["type"];
$size = $_FILES["myfile"]["size"];
$temp = $_FILES["myfile"]["temp_name"];
$error = $_FILES["myfile"]["error"];

if ($error > 0)
   die("Error uploading file! code $error.");
else
{
 move_uploaded_file($temp,"uploaded/".$name);
 echo "upload complete!";
}




?>
i got a parse error from the myfile it is always a fould
yes i now dat i hef to make a file map
User avatar
Chris
Posts: 1581
Joined: Wed Sep 30, 2009 7:22 pm

Re: upload system

Post by Chris »

Code: Select all

<?php 
if ($error > 0)
   die("Error uploading file! code $error.");
 
Waar is je '{'?

Code: Select all

<?php 
if ($error > 0)
{
    die("Error uploading file! code $error.");
 
Fighting for peace is declaring war on war. If you want peace be peaceful.
Falken
Posts: 438
Joined: Fri May 08, 2009 8:03 pm

Re: upload system

Post by Falken »

Chris wrote:

Code: Select all

<?php 
if ($error > 0)
   die("Error uploading file! code $error.");
  
Waar is je '{'?

Code: Select all

<?php 
if ($error > 0)
{
    die("Error uploading file! code $error.");
  
You don't need the { and } in php if you only want to run one line in an if statement. This is perfectly fine php code:

Code: Select all

<?php 
$i = 1;
if($i == 0)
   echo "IT IS ZERO!!!";
else
   echo "IT IS NOT ZERO!!!";
?>
--- Game Database ---
For all your game information needs!
Visit us at: http://www.gamedatabase.eu today!
User avatar
ier
Posts: 67
Joined: Sun Jan 10, 2010 7:32 pm

Re: upload system

Post by ier »

ja maar als ik op de update knop druk zegt de uploader
myfile fout o ja ik heb dit op youtube gevonden bij die man is er geen fout
of veranderen php codes door de jaren.?? want het was van 2008
User avatar
Chris
Posts: 1581
Joined: Wed Sep 30, 2009 7:22 pm

Re: upload system

Post by Chris »

Ik zie er geen fout in, maar voor de zekerheid zou ik {}'s met je ifs gebruiken

Code: Select all

<?php 
if ($error > 0)
{
   die("Error uploading file! code $error.");
}
else
{
   move_uploaded_file($temp,"uploaded/".$name);
   echo "upload complete!";
}
 
En als je met lager dan PHP 4.1 draai zal $_FILES niet werken, je zal $HTTP_POST_FILES moeten gebruiken.
Fighting for peace is declaring war on war. If you want peace be peaceful.
User avatar
ier
Posts: 67
Joined: Sun Jan 10, 2010 7:32 pm

Re: upload system

Post by ier »

nee hij blijft zeggen
Notice: Undefined index: myfile in C:\wamp\www\tut\upload.php on line 4

Notice: Undefined index: myfile in C:\wamp\www\tut\upload.php on line 5

Notice: Undefined index: myfile in C:\wamp\www\tut\upload.php on line 6

Notice: Undefined index: myfile in C:\wamp\www\tut\upload.php on line 7

Notice: Undefined index: myfile in C:\wamp\www\tut\upload.php on line 8
upload complete!
User avatar
Chris
Posts: 1581
Joined: Wed Sep 30, 2009 7:22 pm

Re: upload system

Post by Chris »

En als je <input type='file' name='myfile' id='myfile' /> gebruik?
Fighting for peace is declaring war on war. If you want peace be peaceful.
User avatar
Chris
Posts: 1581
Joined: Wed Sep 30, 2009 7:22 pm

Re: upload system

Post by Chris »

Krijg je dit error ook als je een bestand upload?

Code: Select all

<?php 
if( false === empty($_FILES) && is_array($_FILES) )
{
    $name = $_FILES["myfile"]["name"];
    $type = $_FILES["myfile"]["type"];
    $size = $_FILES["myfile"]["size"];
    $temp = $_FILES["myfile"]["temp_name"];
    $error = $_FILES["myfile"]["error"];

    if ($error > 0)
    {
        die("Error uploading file! code $error.");
    }
    else
    {
        move_uploaded_file($temp,"uploaded/".$name);
        echo "upload complete!";
    }
}
else
{
    echo "No file was uploaded";
}
 
Fighting for peace is declaring war on war. If you want peace be peaceful.
User avatar
ier
Posts: 67
Joined: Sun Jan 10, 2010 7:32 pm

Re: upload system

Post by ier »

nee maar nu zech hij no files uploeded
User avatar
Chris
Posts: 1581
Joined: Wed Sep 30, 2009 7:22 pm

Re: upload system

Post by Chris »

Ja.. waarom denk je.. Kijk naar die code.
Fighting for peace is declaring war on war. If you want peace be peaceful.
Post Reply

Return to “Tutorials”