Small upload website

Caporegime
Joined
25 Jul 2005
Posts
28,851
Location
Canada
I want to have a go at making a small upload website - a bit image shack etc. - where people can upload images using an upload bar and have them automatically resized if they want, then going to a page showing the link and maybe thumbnail version - again a bit like imageshack etc. - How difficult would this be to do via dreamweaver?

Any tips and tricks would be good too as I'm a bit of a beginner. :)
 
Amp34 said:
How difficult would this be to do via dreamweaver?

Any tips and tricks would be good too as I'm a bit of a beginner. :)

Lol....very...I could post the script i use but as i beginner i doubt you will understand it.

You need some server side scripting.
 
Ah ok I though it may be a little difficult. Is the difficulty getting the site to open your documents to choose or the rest of it? What I want to be able to do is upload to my website directly throught the site not via an FTP client. How about just uploading and just showing the link without resizing etc?
 
Very easy to get the 'browe for file' box:

<input type="file" name="file1" />

But the uploading - you'd have to learn php basically. Might be better off looking for a google 'upload script'.
 
That link doesn't seem to work. :(

Ahh looks like theres something wrong with their website at the mo as going through google doesnt work either. :)
 
I'm trying do something similar but I can't get it working.

If anyone could have a look i'd appreciate it.

http://yorkshirejunkies.co.uk/fileupload.php

Code:
<form enctype="multipart/form-data" action="uploader.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>

uploader.php
Code:
$target_path = "uploads/";

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

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

Cheers.
 
Well your first problem is that uploader.php should be like this:

uploader.php
Code:
<?php

$target_path = "uploads/";

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

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

?>

Then there will be other problems, that can be corrected when you do that.
 
This is what I get now.

Parse error: syntax error, unexpected '}', expecting ',' or ';' in /home/.bobinski/admin9588/http/www.yorkshirejunkies.co.uk/uploader.php on line 10

The folder is set to 777.
 
Code:
<?php

$target_path = "uploads/";

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

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    echo "The file ".  basename( $_FILES['uploadedfile']['name']). 
    " has been uploaded";
}
?>

?
 
KingAndora, I was causing a parse error on purpose so i could get the local path.

Perfect, now change it to this and it **should work**, but it won't take care of any of the security issues that come with uploading files:

uploader.php
Code:
<?php

$target_path = "/home/.bobinski/admin9588/http/www.yorkshirejunkies.co.uk/uploads/";

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

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    echo "The file ".  basename( $_FILES['uploadedfile']['name']). 
    " has been uploaded";
}else{
    echo "There was a problem whilst uploading the file";
}
?>
 
Last edited:
I am not sure, I am a newbie at php. Thats why i had to take the long way around and cause a deliberate parse error to get the local path.

There might be a function for it i am not sure, beansprout or someone like that would be able to tell you.

Could come in the form of _FILE_ or something like or $_SERVER['PHP_SELF'], but again i haven't a clue tbh.


EDIT:

Take a look at this phazer: Linky

If you a looking specifically for an image uploader, then there are certain security precautions that should be taken.
 
Last edited:
Back
Top Bottom