this script compiles and seems to look fine but im no great scripter. when i try to upload an image it runs the script but it dosnt upload the image. iv set the file im uploading to as 777 whats wrong in this script it worked fine befor i added the image name form.
PHP Code:
<?
//set these variables-----------------------------------------------------------------
$domain = "www.sitename.com/Cruise"; //your domainname
$path = "../Cruise/mGallery/home/"; //path to your targetfolder
$path_after_domain = "mGallery/home/"; //path to your targetfolder for use in url
$max_size = 100000; //maximum filesize
//------------------------------------------------------------------------------------
?>
<span class="text_mainhead">Image Upload</span> <br>
<FORM ACTION="gallery_update.php" METHOD="POST" ENCTYPE="multipart/form-data" class="maintext">
<table width="100%" border="0" cellpadding="5">
<tr>
<td class="text_main">Image Name: </td>
<td><input name="namefile" type="text" class="text_main" size="40">
<span class="text_main">(dont include .jpg)</span></td>
</tr>
<tr>
<td><span class="text_main">IMAGE (jpg)</span></td>
<td><input name="userfile" type="file" class="text_main" size="40">
<input name="submit" type="submit" class="text_main" onClick="MM_validateForm('namefile','','R');return document.MM_returnValue" value="Upload"></td>
</tr>
</table>
</FORM>
<br>
<?
if (!isset($HTTP_POST_FILES['userfile'])) exit;
if (!isset($HTTP_POST_FILES['namefile'])) exit;
if (is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'])) {
if ($HTTP_POST_FILES['userfile']['size']>$max_size) {
echo "<font color=\"#333333\" face=\"Geneva, Arial, Helvetica, sans-serif\">File is too big !</font><br>\n"; exit; }
if (($HTTP_POST_FILES['userfile']['type']=="image/gif") || ($HTTP_POST_FILES['userfile']['type']=="image/pjpeg") || ($HTTP_POST_FILES['userfile']['type']=="image/jpeg")) {
if (file_exists($path . $HTTP_POST_FILES['userfile']['name'])) {
echo "<font color=\"#333333\" face=\"Geneva, Arial, Helvetica, sans-serif\">There already exists a file with this name, please rename your file and try again</font><br>\n"; exit; }
$res = copy($HTTP_POST_FILES['userfile']['tmp_name'], $path .$HTTP_POST_FILES['namefile']. ".jpg");
if (!$res) { echo "<font color=\"#333333\" face=\"Geneva, Arial, Helvetica, sans-serif\">Didn't work, please try again</font><br>\n"; exit; } else {
?>
<br> <?
}
echo "<font color=\"#333333\" face=\"Geneva, Arial, Helvetica, sans-serif\"><hr>";
echo "Name: ".$HTTP_POST_FILES['userfile']['name']."<br>\n";
echo "Size: ".$HTTP_POST_FILES['userfile']['size']." bytes<br>\n";
echo "Type: ".$HTTP_POST_FILES['userfile']['type']."<br>\n";
echo "</font>";
echo "<br><br><img src=\"http://" . $domain . "/" . $path_after_domain . $_SESSION['MM_Username'] . ".jpg\">";
} else { echo "<font color=\"#333333\" face=\"Geneva, Arial, Helvetica, sans-serif\">File must be a jpg !!!</font><br>\n"; exit; }
}
?>
|