Ok, I want allow the user to use their own background image for their home page and I want to do something like this. Where when the image is uploaded it will translate into text data and will be saved in a cookie so when ever the user comes back the image will display on the home page:
http://software.hixie.ch/utilities/cgi/data/data
Any links or code?
Thanks, Ajm.
Here is a simple upload script that will allow certain files to be uploaded, after upload you can execute a query to the path of the image in the users information.
Page name: x.php
[php]
<?php
$target = "upload/path/insert/here/";
$target = $target . basename( $_FILES['file']['name']);
$image=($_FILES['file']['name']);
if (chk_file($image)) { $error = "Invalid Extension"; echo("<pre><center>"); echo($error); echo("</pre></center>"); exit; }
if($_POST['file'] == "") { $error = "Please upload your file."; }
if(!chk_file($image) && move_uploaded_file($_FILES['file']['tmp_name'], $target) && isset($image))
{
$error = "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded.";
//echo("<img src=\"{$target}\">");
//Insert mysql statement here
echo($error);
}
elseif (is_uploaded_file($_FILES['file']['tmp_name']) == FALSE && $_POST['file'] != "") {
$error = "Sorry, there was a problem uploading your file.";
}
?>
<?php
function chk_file($file) {
$approve = Array('1' => '.JPG', '2' => '.GIF', '3' => '.PNG');
$deny = Array('1' => '.exe', '2' => '.php');
$str = strtoupper($file);
foreach ($approve as $id=>$ext) {
if (preg_match("/$ext/i", $str)) {
$status = false;
}
}
foreach ($deny as $id=>$ext) {
if (preg_match("/$ext/i", $str)) {
$status = true;
}
}
return $status;
}
?>
[/php]
[html]
<center>
<?php echo($error); ?>
<pre>
<form action="x.php" method="POST" enctype="multipart/form-data" class="style2">
<div align="center">
File: <input type="file" name="file"><br>
<input name="Submit" type="submit" class="style1" value="Add"><br />
</div>
</form>
</pre>
</center>
[/html]