Forum Moderators: coopster
i can't seem to get it to work without using input="file" in the form. is there a simple way to get this to work?
<html>
<body>
<form action="upload_file.php" method="post"
enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file" />
<br />
<input type="submit" name="submit" value="Submit" />
</form>
</body>
</html>
upload_file.php
<?php
if (($_FILES["file"]["type"] == "image/gif")
¦¦ ($_FILES["file"]["type"] == "image/jpeg")
¦¦ ($_FILES["file"]["type"] == "image/pjpeg")
&& ($_FILES["file"]["size"] < 300000))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
if (file_exists("upload/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $_FILES["file"]["name"]);
echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
}
}
}
else
{
echo "Invalid file";
}
?>
[edited by: master_w_bates_III at 3:43 pm (utc) on Dec. 14, 2007]
I am very certain that this is possible. here is an example. The form is located at the bottom of the page.
<snip>
here is the html for the form
<div id="fromurl">
<input type="text" name="img_url" value="http://" MAXLENGTH=512><br>
<font size="1">Enter the picture url, example: <i>http://example.com/picture.jpg</i></font>
<br>
</div>
photobucket also has a similar feature. There must be some server side command to make this work.
Ideally what I want to happen is for the image to be transfered from a remote url, and placed into an uploaded pictures folder on my webserver. then to have the local image url referenced in my database.
[edited by: eelixduppy at 10:57 am (utc) on Dec. 15, 2007]
[edit reason] no URLs, please [/edit]
Try reading [php.net...] for examples