romu58
Messages postés2Date d'inscriptionjeudi 2 juin 2005StatutMembreDernière intervention23 août 2006
-
23 août 2006 à 12:45
romu58
Messages postés2Date d'inscriptionjeudi 2 juin 2005StatutMembreDernière intervention23 août 2006
-
23 août 2006 à 22:10
Bonjour à tous,
Débutant en PHP ,j'ai un scxcript upload pour mon forum mais le soucis j'arrive pas a avoir le lien de téléchargement apres voici le script en question :
<?php
/* loading language file */
function get_translations($lngfile) {
if (file_exists($lngfile)) {
$lines = file($lngfile);
while (list(,$line) = each($lines)) {
list($key,$val)= explode("=",$line);
$phrases[$key] = $val;
}
return $phrases;
} else {
return false;
}
}
/* translate a string */
function translate($str,$vals="") {
if (!ereg("^4",phpversion())) {
function in_array($needle,$haystack) { # we have this function in PHP4, so for you PHP3 people
for ($i=0; $i < count($haystack); $i++) {
if ($haystack[$i] == $needle) {
return true;
}
}
}
}
# --
function validate_upload($the_file) {
global $my_max_file_size, $image_max_width, $image_max_height,$allowed_types,$the_file_type,$registered_types;
$start_error = "\n Error: \n";
if ($the_file == "none") { # do we even have a file?
$error .= "\n<li>You did not upload anything!</li>";
} else { # check if we are allowed to upload this file_type
if (!in_array($the_file_type,$allowed_types)) {
$error .= "\n<li>The file that you uploaded was of a type that is not allowed, you are only
allowed to upload files of the type:\n";
while ($type = current($allowed_types)) {
$error .= "\n<li>" . $registered_types[$type] . " (" . $type . ")</li>";
next($allowed_types);
}
$error .= "\n";
}
if (ereg("image",$the_file_type) && (in_array($the_file_type,$allowed_types))) {
$error = validate_upload($the_file);
if ($error) {
form($error);
} else { # cool, we can continue
if (!@copy($the_file, $the_path . "/" . $the_file_name)) {
form("\n Something barfed, check the path to and the permissions for the upload directory ");
} else {
list_files();
form();
}
}
} # END upload