How can I get only the filename and not the complete path of a file when I use: <input name=\"Image\" type=\"FILE\">$_FILES['Image']['name']
<!-- m --><a class="postlink" href="http://ca3.php.net/manual/en/features.file-upload.php#features.file-upload.post-methodOk">http://ca3.php.net/manual/en/features.f ... t-methodOk</a><!-- m -->, now I understand it well, but it's returning nothing. Any idea why.do a
print_r($_FILES['Image']);
i think that's the syntax for print_r
see what you get!
one other thing... do the folders where you copying the stuff have the right permissions?
here's the code i use for one of my site
$base_path = "/home/karinne/karinnelegault.com/fcoutaouais/images/nouvelles/".$_FILES['image']['name'];
copy($_FILES['image']['tmp_name'], $base_path);
chmod ($base_path, 0644);I have the right permissions on the folder.
I got a notice error Image not defined.
Also, what print_r is supposed to do?print_r is like echo but for arrays
<!-- m --><a class="postlink" href="http://ca2.php.net/manual/en/function.print-r.php">http://ca2.php.net/manual/en/function.print-r.php</a><!-- m -->
ok so... what's the code you're using?!Here's the code
<html>
<head>
<title>Uploader une photo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
//Dé—ÂÂ弆aration et initialisation
//Checker la fonction isset
$iCtr = 1;
$Num = 0;
$Action = "";
$Section = $_GET["ListeSection"];
$QuerySection = "SELECT Section, NomTable FROM configimages ORDER BY Section;";
$db = mysql_connect("localhost", "Sam")
or die ("Impossible de se connecter ?la base de donné—ÂÂ憇");
mysql_select_db("melville",$db)
or die ("Impossible de sé—ÂÂ榚ctionner la base de donné—ÂÂ憇");
$result = mysql_query($QuerySection,$db);
$Num = mysql_num_rows($result);
//Vé—ÂÂ瀒fie si la db n'est pas vide
if($myrow = mysql_fetch_array($result))
{
//Vé—ÂÂ瀒fie si on doit ajouter une image ou afficher la forme.
if ($_GET["Submit"]=="True")
{
$QueryInsert = "INSERT INTO ".$myrow["NomTable"]." VALUES (
'".$myrow["NomTable"]."/".$_FILES['Image']['name']."','".$_POST["Description"]."'
);";
//Uploadage de l'image sur le serveur
$newfile = $myrow["NomTable"] . "/" . $_FILES['Image']['name'];
if(copy($_POST["Image"], $newfile))
{
print("<h3> UPLOAD SUCCESSFUL!</h3>");
}
else
{
print("<h3>ERROR UPLOADING FILE!</h3>");
}
mysql_query($QueryInsert,$db);
printf ("<form name=\"Photos\" method=\"post\"
action=\"%s?ListeSection=%s&Submit=False\">",$_SERVER['PHP_SELF'],$_GET["ListeSection"]);
echo "<p></p>";
echo "<p align=\"center\">L'image a é—ÂÂ
<!-- m --><a class="postlink" href="http://ca3.php.net/manual/en/features.file-upload.php#features.file-upload.post-methodOk">http://ca3.php.net/manual/en/features.f ... t-methodOk</a><!-- m -->, now I understand it well, but it's returning nothing. Any idea why.do a
print_r($_FILES['Image']);
i think that's the syntax for print_r
see what you get!
one other thing... do the folders where you copying the stuff have the right permissions?
here's the code i use for one of my site
$base_path = "/home/karinne/karinnelegault.com/fcoutaouais/images/nouvelles/".$_FILES['image']['name'];
copy($_FILES['image']['tmp_name'], $base_path);
chmod ($base_path, 0644);I have the right permissions on the folder.
I got a notice error Image not defined.
Also, what print_r is supposed to do?print_r is like echo but for arrays
<!-- m --><a class="postlink" href="http://ca2.php.net/manual/en/function.print-r.php">http://ca2.php.net/manual/en/function.print-r.php</a><!-- m -->
ok so... what's the code you're using?!Here's the code
<html>
<head>
<title>Uploader une photo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
//Dé—ÂÂ弆aration et initialisation
//Checker la fonction isset
$iCtr = 1;
$Num = 0;
$Action = "";
$Section = $_GET["ListeSection"];
$QuerySection = "SELECT Section, NomTable FROM configimages ORDER BY Section;";
$db = mysql_connect("localhost", "Sam")
or die ("Impossible de se connecter ?la base de donné—ÂÂ憇");
mysql_select_db("melville",$db)
or die ("Impossible de sé—ÂÂ榚ctionner la base de donné—ÂÂ憇");
$result = mysql_query($QuerySection,$db);
$Num = mysql_num_rows($result);
//Vé—ÂÂ瀒fie si la db n'est pas vide
if($myrow = mysql_fetch_array($result))
{
//Vé—ÂÂ瀒fie si on doit ajouter une image ou afficher la forme.
if ($_GET["Submit"]=="True")
{
$QueryInsert = "INSERT INTO ".$myrow["NomTable"]." VALUES (
'".$myrow["NomTable"]."/".$_FILES['Image']['name']."','".$_POST["Description"]."'
);";
//Uploadage de l'image sur le serveur
$newfile = $myrow["NomTable"] . "/" . $_FILES['Image']['name'];
if(copy($_POST["Image"], $newfile))
{
print("<h3> UPLOAD SUCCESSFUL!</h3>");
}
else
{
print("<h3>ERROR UPLOADING FILE!</h3>");
}
mysql_query($QueryInsert,$db);
printf ("<form name=\"Photos\" method=\"post\"
action=\"%s?ListeSection=%s&Submit=False\">",$_SERVER['PHP_SELF'],$_GET["ListeSection"]);
echo "<p></p>";
echo "<p align=\"center\">L'image a é—ÂÂ