upload script werkt niet

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Ralph van der Tang

ralph van der Tang

07/05/2013 11:10:44
Quote Anchor link
hoi iedereen,

ik wil profiel foto's gaan uploaden maar nu wil mijn upload script niet:

hij blijft hangen in de status loading.

javascript
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php
function uploadimg(theform){
    theform.submit();
    
    setStatus("Loading...", "gebruikersAanmakenProfielFoto");
    return false;
}
function
doneloading(rezultat) {
  rezultat = decodeURIComponent(rezultat.replace(/\+/g,  " "));
  document.getElementById('gebruikersAanmakenProfielFoto').innerHTML = rezultat;
}

function
setStatus(theStatus, theloc) {
  var
tag = document.getElementById(theloc);

  if (tag) {
    tag.innerHTML = '<b>'+ theStatus + "</b>";
  }
}

?>

HTML
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
<div id="gebruikersAanmakenProfielFoto">
                <
form target="uploadframe" id="uploadform" action="'.Settings::$url.'/admin/upload_profile_img.php" method="post" enctype="multipart/form-data" onSubmit="uploadimg(this); return false">
                    <
p><b>Profielfoto : </b></p>
                    <
table>
                        <
tr>
                            <
td>Profielfoto :</td><td><input type="file" id="gebruikersAanmakenProfielPic"></td>
                        <
/tr>
                        <
tr>
                            <
td></td><td><input type="submit" value="Submit"></td>
                        <
/tr>
                    <
/table>
                    <
iframe name="uploadframe" id="uploadframe" name="uploadframe"  src="'.Settings::$url.'/admin/upload_profile_img.php" width="8" height="8" scrolling="no" frameborder="0"></iframe>
                <
/form>
            <
/div>
?>


upload_profile_img.php
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
function __autoload($class_name)
{

        include_once('../includes/class_'. strtolower($class_name) . '.php');
}


$savefolder = Settings::$url.'/uploaded/avatar_realsize/test';        // folder for upload
$max_size = 1024 * 5;            // maxim size for image file, in KiloBytes

// Allowed image types

$allowtype = array('bmp', 'gif', 'jpg', 'jpeg', 'gif', 'png');

/** Uploading the image **/

$rezultat = '';
// if is received a valid file
if (isset ($_FILES['myfile'])) {
  // checks to have the allowed extension
  $type = end(explode(".", strtolower($_FILES['myfile']['name'])));
  if (in_array($type, $allowtype)) {
    // check its size
    if ($_FILES['myfile']['size']<=$max_size*1000) {
      // if no errors
      if ($_FILES['myfile']['error'] == 0) {
        $thefile = $savefolder . "/" . $_FILES['myfile']['name'];
        // if the file can`t be uploaded, return a message
        if (!move_uploaded_file ($_FILES['myfile']['tmp_name'], $thefile)) {
          $rezultat = 'The file can`t be uploaded, try again';
        }

        else {
          // Return the img tag with uploaded image.
          $rezultat = '<img src="'.$thefile.'" />';
          echo 'The image was successfully loaded';
        }
      }
    }

    else { $rezultat = 'The file <b>'. $_FILES['myfile']['name']. '</b> exceeds the maximum permitted size <i>'. $max_size. 'KB</i>'; }
  }

  else { $rezultat = 'The file <b>'. $_FILES['myfile']['name']. '</b> has not an allowed extension'; }
}


// encode with 'urlencode()' the $rezultat and return it in 'onload', inside a BODY tag
$rezultat = urlencode($rezultat);
echo '<body onload="parent.doneloading(\''.$rezultat.'\')"></body>';
?>



Toevoeging op 07/05/2013 11:10:58:

iemand suggesties?
Gewijzigd op 07/05/2013 11:35:14 door Ralph van der Tang
 
PHP hulp

PHP hulp

05/11/2024 22:06:07
 
Albert de Wit

Albert de Wit

07/05/2013 11:17:55
Quote Anchor link
Ja, ik heb 3 suggesties. Haal je
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?php ?>
tags weg waar ze niet horen.
 
Ralph van der Tang

ralph van der Tang

07/05/2013 11:34:16
Quote Anchor link
mssn wel handig


Toevoeging op 07/05/2013 11:35:26:

waren kopieer foutjes


Toevoeging op 07/05/2013 13:51:10:

het probleem is dat het plaatje niet wordt ingeladen in het Iframe iemand die mij daar mee kan helpen?
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.