uploading files

They have: 71 posts

Joined: Oct 2005

i want to have a section of my site where users can upload files.

anyone know how i can achive this effect!

i am currectly using HTML code.

Busy's picture

He has: 6,151 posts

Joined: May 2001

You'll need some server side code ideally (PHP, ASP, CF etc)

HTML can create the form but not the transfer or validation of the upload. Then you may also need a database to store the uploaded file names etc.

Does your host allow server side scripting? If so which.

He has: 1 posts

Joined: Jan 2006

Here's a free script you can try:
http://tech.tailoredweb.com/simple-upload-53.php
Filesize limits will depend on your hosts php.ini.

He has: 31 posts

Joined: Jan 2004

hi i used something similar but one problem i have is if a user uploads a file with the same name as an existing file it other writes.. how can the you change the names so the file name is like 768946975.jpg instead of me.jpg?

the code i use is

-----------------------------------

<?php
$target_path
= "images1/";

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);

if(
move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    echo
"<b>The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded</b>";
} else{
    echo
"There was an error uploading the file, please try again!";
}
?>

----------------------------------

the images1/ is the upload directory. the user then fills out title and description in a form and things like date, file id are hidden fields with echo of necessary info.

any help would be grateful

thanks Mullet

Busy's picture

He has: 6,151 posts

Joined: May 2001

depends where the 768946975 comes from, is it the user's id, time, random number ...

http://php.net/manual/en/function.move-uploaded-file.php

He has: 31 posts

Joined: Jan 2004

i would get it by using time..

<?php
echo date("mHiyd");
?>

thanks again for your help..

He has: 31 posts

Joined: Jan 2004

i just need any way to rename the file either by adding the username to file like user_image.file_type or just a random code like 45h78s760i87.gif. i still using the code above

any help please..

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.