Log in

View Full Version : Looking for help!



jerseychego
10-05-2014, 07:14 AM
Hello!

My website is in the process of being updated. It is a craft mall for crafters to sell their crafts through my site.

What I am doing for the update is to have a way for crafters to login into their account and update their listings without having me do it for them. I also am looking for a way that they can upload their images as well. You know when you go to upload an image or a document and you hit the browse button - to take it off of your computer to put onto the website you are part of - that is what I am looking for as well.

If anyone has any idea of how to write that or even where I can find the script, I would greatly appreciate it!

Thanks so much!

alexyahaloms
10-31-2014, 08:21 PM
The HTML Code for upload/browse


<h1>UPLOADING FILES</h1>
<form name="fupload" enctype="multipart/form-data" action="upfiles.php" method="post">
<input type="file" name="picture" />
<input type="submit" value="Submit" />
</form>
</body>

PHP code is...
Your "upfiles.php":

<header>
<?php
function UploadOne($fname)
{
$uploaddir = 'uploadedfiles/';
if (is_uploaded_file($fname['tmp_name']))
{
$filname = basename($fname['name']);
$uploadfile = $uploaddir . basename($fname['name']);
if (move_uploaded_file ($fname['tmp_name'], $uploadfile))
$res = "File " . $filname . " was successfully uploaded and stored.<br>";
else
$res = "Could not move ".$fname['tmp_name']." to ".$uploadfile."<br>";
}
else
$res = "File ".$fname['name']." failed to upload.";
return ($res);
}
?>
</header>
<body>
<?php
if ($_FILES['picture']['name'] != "")
{
$res = UploadOne($_FILES['picture']);
$filname = $_FILES['picture']['name'];
echo ($res);
}
?>