Jump to content

upload button customized


zeusthegreat

Recommended Posts

what i want to do basically is to use an upload button to upload pictures and word docs to a specific page on my site lets say picture_page.php

 

 

 

 

 

 

<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>

 

 

 

this file is called form_new.php

 

do i need to customize the upload_file.php to lets the picture_page.php

 

<?php

if ($_FILES["file"]["error"] > 0)

{

echo "Error: " . $_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 "Stored in: " . $_FILES["file"]["tmp_name"];

}

?>

 

 

and then the next page is called say --- upload_file.php

 

do i have to customize on this page

tmp_name to picture_page_name

 

 

 

<?php

if ((($_FILES["file"]["type"] == "image/gif")

|| ($_FILES["file"]["type"] == "image/jpeg")

|| ($_FILES["file"]["type"] == "image/pjpeg"))

&& ($_FILES["file"]["size"] < 20000))

{

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";

}

?>

lets say this page is called Saving_upload.php

 

do i have to alter echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";

to echo "Picture_page file: " . $_FILES["file"]["Picture_Page_name"] . "<br />";

and

 

move_uploaded_file($_FILES["file"]["tmp_name"],

to move_uploaded_file($_FILES["file"]["picture_page_name"],

 

 

<?php

if ((($_FILES["file"]["type"] == "image/gif")

|| ($_FILES["file"]["type"] == "image/jpeg")

|| ($_FILES["file"]["type"] == "image/pjpeg"))

&& ($_FILES["file"]["size"] < 20000))

{

if ($_FILES["file"]["error"] > 0)

{

echo "Error: " . $_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 "Stored in: " . $_FILES["file"]["tmp_name"];

}

}

else

{

echo "Invalid file";

}

?>

 

 

 

this page is called restriction_upload.php

do i have to alter the below to

 

 

 

 

echo "Stored in: " . $_FILES["file"]["tmp_name"];

 

 

 

echo "Stored in: " . $_FILES["file"]["picture_page_name"];

 

 

 

am i on the right track

 

 

how do i then get the picture_page.php to show the docs or picys

 

 

guidance would be great!!! :lol::lol::lol:

Link to comment
Share on other sites

Where are you getting this code from? Are you following a specific tutorial?

 

It seems like you have a lot of pages that all do about the same thing: upload_file.php/Saving_upload.php/restriction_upload.php.

 

All you need is one file for your form, one file that processes the form and uploads the file, and (eventually) one file that displays the files uploaded.

 

This tutorial looks like it's very close to what you need: http://net.tutsplus.com/tutorials/php/online-file-storage-with-php/

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...