Jump to content

[SOLVED] PHP File uploader help


freaka

Recommended Posts

Hey guys, I'm working on a file upload script for my site and i need a little help. I have a file upload script that I had some help writing, but I want to be able to select some options for the file that's being uploaded. I want to be able to choose the type of file (ie: music, software, video, misc), the author of the file, and a small description of the file. Also, depending on the file type, i would want the file to be uploaded to a different directory (music would go to music, software in software, etc.) This is the code that I'm working with.

 

<?php
$target = "upload/";
$target = $target . basename( $_FILES['uploaded']['name']) ;
$ok=1;

//This is our size condition
if ($uploaded_size > 350000)
{
echo "Your file is too large.<br>";
$ok=0;
}

//This is our limit file type condition
if ($uploaded_type =="text/php")
{
echo "No PHP files<br>";
$ok=0;
}

//Here we check that $ok was not set to 0 by an error
if ($ok==0)
{
Echo "Sorry your file was not uploaded";
}

//If everything is ok we try to upload it
else
{
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
}
else
{
echo "Sorry, there was a problem uploading your file.";
}
}
?> 

 

If you guys could help me out i would really appreciate it. Thanks in advance!

Link to comment
https://forums.phpfreaks.com/topic/117410-solved-php-file-uploader-help/
Share on other sites

is everything you're doing right now working properly?

 

if so....

 

you need to add some more inputs to your form for the extra information you need. I'd suggest to make the php a bit easier, use JAvascript to check to make sure that the required fields are filled in before letting the person submit.  this reduces the complexity of the php file and saves time for you and the user.

 

once you have this set up, you want to write your php script that gets the variables from the form and inputs them into the database along with the path of the associated image.

 

does this all make sense?  do you have much prior php knowledge?

 

 

-Grant

hmm valid problem with the blocking of javascript.

 

 

well i'd say familiarize yourself more with php and mysql and how they work together

 

check out...

 

http://www.php-mysql-tutorial.com/

 

that's from 5 seconds of googling. 

 

try doing some tutorials and the solutions to your problems will reveal themselves.

 

let me know if you have any directions.  googling is often the best resource....and the tutorials on this site.

 

ttyl

 

-grant

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.