Page 1 of 1
need help on a script.
Posted: Thu Jan 19, 2006 7:22 am
by Circle
I'm just beginning to learn PHP but I need something done I can't do myself yet and would like some one to help me with it.
I need a script on my website that allows users/people to upload theire pictures. I don't know if sutch a script is allready avalible somewhere but I'm not able of finding it at the moment.
If possible I would like the page password protected.
I hope some one can help me with this one.
*I posted this in a other forum before but thought it would suit better in here so I deleted it in there.*
Posted: Thu Jan 19, 2006 7:39 am
by Jenk
viewtopic.php?t=43069
That thread may be of use to you
If not, have a look at the example given in the php manual for the function move_uploaded_file() and if you get stuck, post here with your problem(s) and I'm sure you will get help

Posted: Thu Jan 19, 2006 7:47 am
by Circle
Thanks but I'm not looking for no gallery.
I would like some members of my site to be able of uploading their pictures something like
http://www.imageshack.us does but if possible password protected so only those who I allow to can use the function.
Posted: Thu Jan 19, 2006 7:57 am
by Circle
feyd | Please use Code: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
I looked at the html code imageshack uses but don't know what part of it I would need for what I want. I some one could help me the code is:
Code: Select all
<html>
<head>
<title>ImageShack(tm) - Hosting</title>
<link rel="stylesheet" href="img/style-def.css" type="text/css">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
<script type="text/javascript">
var url = "http://imageshack.us/";
var title = "ImageShack.us® - Image Hosting";
function highlight(field) {
field.focus();
field.select();
}
function phpbb(){
window.open ('phpbb.php', 'phpbb', config='height=450, width=720, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no');
}
function vb(){
window.open ('vb.php', 'vb', config='height=450, width=720, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no');
}
function sm(){
window.open ('sm.php', 'sm', config='height=450, width=720, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no');
}
function ipb(){
window.open ('ipb.php', 'ipb', config='height=450, width=720, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no');
}
function favorites(){
if(document.all)
window.external.AddFavorite(url,title)
}
function disableme (what) {
what = document.getElementById(what);
what.disabled = true;
what.value="uploading...";
}
function validateForm(theForm)
{
if (theForm.name.value=="" ||theForm.email.value=="" ||theForm.subj.value=="" ||theForm.idea.value==""||theForm.email.value.indexOf("@")==-1 || theForm.email.value.indexOf(".") == -1) {
alert("ERROR: Either you did not fill the form out to completion, or your email address is incorrect.");
return false;
}
if (theForm.corr.selectedIndex==0) {
alert("You must select a 'Reason for Email' from the drop-down box.");
return false;
}
}
var buttonname = '"Browse..."';
function showoptions(what) {
var ext = what.value.substr(what.value.length - 3,3).toLowerCase();
switch (ext) {
case 'jpg':
case 'peg':
case 'png':
case 'gif':
case 'bmp':
case 'tif':
case 'iff':
document.getElementById('resizeoptions').style.display='';
document.getElementById('filetypeerror').style.display='none';
document.getElementById('butan').disabled=false;
document.getElementById('butan').value='host it!';
break;
case 'swf':
document.getElementById('resizeoptions').style.display='none';
document.getElementById('filetypeerror').style.display='none';
document.getElementById('butan').disabled=false;
document.getElementById('butan').value='host it!';
break;
case '':
document.getElementById('butan').disabled=true;
document.getElementById('butan').value=buttonname;
default:
document.getElementById('resizeoptions').style.display='none';
document.getElementById('filetypeerror').style.display='';
document.getElementById('butan').disabled=true;
document.getElementById('butan').value='bad file type';
break;
}
}
function doload() {
what = document.getElementById('butan');
if (document.getElementById('fileupload').value == '') {
what.disabled=true;
what.value = 'select an image using ' + buttonname;
document.getElementById('resizeoptions').style.display='none';
}
document.getElementById('optsize').disabled = !document.getElementById('optimage').checked;
}
function toggleuploadmode(file) {
if (file) {
document.getElementById('upfile').style.display='block';
document.getElementById('upurl').style.display='none';
document.getElementById('upform').action='http://www.imageshack.us/index.php';
} else {
document.getElementById('upfile').style.display='none';
document.getElementById('upurl').style.display='block';
document.getElementById('upform').action='http://www.imageshack.us/transload.php';
}
}
function focusfield(fl) {
if (fl.value=="paste image url here") {
fl.value='';
fl.style.color='black';
}
}
-->
</script>
</head>
<body bgcolor="#F7F7F7">
<table width="760" cellspacing="0" cellpadding="0" border="0" align="center"><tr><td><a href="http://imageshack.us/"><img alt="ImageShack® Logo" src="img/imageshack.png" title="" /></a></td><td valign="bottom" align="left">
<b><a href="http://imageshack.us/">ImageShack(tm)</a>
| <a href="http://blog.imageshack.us/">PhotoBlogging</a>
| <a href="http://reg.imageshack.us/content.php?page=features">Tools</a>
| <a href="http://reg.imageshack.us/content.php?page=faq">Common Questions</a>
| <a href="http://reg.imageshack.us/content.php?page=rules">Terms of Service</a>
| <a href="http://reg.imageshack.us/content.php?page=register">My Images</a> | <a href="https://www.paypal.com/xclick/business=macbeth%40imageshack.us&item_name=Donation&no_note=1&tax=0¤cy_code=USD">Donate</a>
</b>
</td></tr></table>
<div class="don" style="color: #ccc">img352 at 209.172.60.20</div>
<table cellpadding="5" width="760" border="1" bordercolor="#CCCCCC" class="table_decoration"
align="center"><tr>
<td valign="top"><!-- FASTCLICK.COM 300x250 Medium Rectangle CODE for imageshack.us -->
<script language="javascript" src="http://media.fastclick.net/w/get.media?sid=20143&m=6&tp=8&d=j&t=n"></script>
<noscript><a href="http://media.fastclick.net/w/click.here?sid=20143&m=6&c=1" target="_blank">
<img src="http://media.fastclick.net/w/get.media?sid=20143&m=6&tp=8&d=s&c=1"
width=300 height=250 border=1></a></noscript>
<!-- FASTCLICK.COM 300x250 Medium Rectangle CODE for imageshack.us -->
</td><td valign="top"><p>Welcome, <b>google.nl</b> visitor!</p><p>To upload an image, click "Browse...", select an
image, click OK/Open, and then click the "host it!" button. After a short while, your image will upload.
Depending on your use for the image, use any one of the provided linking codes. </p><p><b>New to ImageShack? <a href="http://reg.imageshack.us/content.php?page=faq">Click to learn more!</a></b></p><a href="http://reg.imageshack.us/content.php?page=rules">
<img src="banmessage.png" class="para" alt="hosting" border="0" /></a>
<form method="post" action="http://imageshack.us/index.php" enctype="multipart/form-data" onsubmit="disableme('butan')" id="upform">
<table cellspacing="0" cellpadding="0" border="0"><tr>
<td><p>upload from: <input type="radio" name="uploadtype" onclick="toggleuploadmode(true);" checked> file <input type="radio"
name="uploadtype" onclick="toggleuploadmode(false);"> url</p></td>
<td width="10"> </td>
<td><div id="upfile"><input type="file" name="fileupload" size="30" onchange="showoptions(this)" id="fileupload"></div>
<div id="upurl" style="display: none"><input type="text" id="fileupload" value="paste image url here" style="color: #888;"
onfocus="focusfield(this)" name="url" size="30"></div></td>
</tr></table>
<input type="hidden" name="MAX_FILE_SIZE" value="3145728">
<input type="hidden" name="refer" value="http://www.google.nl/search?client=firefox-a&rls=org.mozilla%3Anl%3Aofficial_s&hl=nl&q=image+hosting&meta=&btnG=Google+zoeken">
<input type="hidden" name="brand" value="">
<div id="resizeoptions">
<input type="checkbox" name="optimage" id="optimage" value="1" onclick="optsize.disabled=!this.checked"> resize image?
<select name="optsize" id="optsize">
<option value="100x100" >100x75 (avatar)</option>
<option value="150x150" >150x112 (thumbnail)</option>
<option value="320x320" selected>320x240 (for websites and email)</option>
<option value="640x640" >640x480 (for message boards)</option>
<option value="800x800" >800x600 (15-inch monitor)</option>
<option value="1024x1024" >1024x768 (17-inch monitor)</option>
<option value="1280x1280" >1280x1024 (19-inch monitor)</option>
<option value="1600x1600" >1600x1200 (21-inch monitor)</option>
<option value="resample" >optimize without resizing</option>
</select>
</div>
<div>
<input type="checkbox" name="rembar" value="1" > remove size/resolution bar from thumbnail?
</div>
<div id="filetypeerror" style="display: none"> <b style="color: red;">Please select only one of the supported file types:</b><br></div>
<div><img class="para" src="img/hosty.png" alt="hosting" /></div>
<input id="butan" style="padding-left: .5em; padding-right: .5em;" type="submit" value="host it!" ></form>
<p><a rel="sidebar" title="ImageShack® - Sidebar" href="http://imageshack.us/index4.php"
onclick="window.external.AddFavorite(location.href,document.title); window.sidebar.addPanel(document.title,
location.href,'');"><b>Bookmark ImageShack's Sidebar!</b></a></p></td></tr></table><div align="center" class="links">
<a href="http://reg.imageshack.us/content.php?page=rules">Copyright</a> © 2003-2005 <a
href="http://reg.imageshack.us/content.php?page=aboutus">ImageShack Corp</a>. All
rights reserved. <a href="http://reg.imageshack.us/content.php?page=linkto">Link to ImageShack</a>
<br />
<a href="http://reg.imageshack.us/content.php?page=email&q=marketing">Marketing Opportunities</a> |
<a href="http://reg.imageshack.us/content.php?page=email&q=abuse">Report Abuse or Request Deletion</a> |
<a href="http://reg.imageshack.us/content.php?page=email&q=customer">Customer Service</a>
<br />
<a href="http://reg.imageshack.us/content.php?page=email">Contact ImageShack</a>
</div>
<br /><table width="366" cellspacing="0" cellpadding="3" border="0" class="table_decoration" align="center">
<tr><td bgcolor="#F7F7F7"><b><a href="http://reg.imageshack.us/content.php?page=quicksend" title="Upload images to ImageShack by emailing images as attachments. QuickSend is compatible with cameraphones!">ImageShack QuickSend</a></b> (#5 of <a
href="http://reg.imageshack.us/content.php?page=features" >8
features</a>)</td></tr><tr><td>
Upload images to ImageShack by emailing images as attachments. QuickSend is compatible with cameraphones!</td></tr></table><br /><table width="250" cellspacing="0" cellpadding="5" border="0" class="table_decoration" align="center"><tr><td><!-- FASTCLICK.COM 300x250 Medium Rectangle CODE for imageshack.us -->
<script language="javascript" src="http://media.fastclick.net/w/get.media?sid=20143&m=6&tp=8&d=j&t=n"></script>
<noscript><a href="http://media.fastclick.net/w/click.here?sid=20143&m=6&c=1" target="_blank">
<img src="http://media.fastclick.net/w/get.media?sid=20143&m=6&tp=8&d=s&c=1"
width=300 height=250 border=1></a></noscript>
<!-- FASTCLICK.COM 300x250 Medium Rectangle CODE for imageshack.us -->
</td></tr></table>
</body>
</html>
feyd | Please use Code: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Posted: Thu Jan 19, 2006 7:57 am
by Jenk
ok, in that case, take a look at the move_uploaded_file function on the php manual.
You'll generally find on these forums we don't just do things for you, we prefer you learn and we will happily offer advice when you get stuck..
Posted: Thu Jan 19, 2006 8:03 am
by matthijs
Hi circle, if you search this forum and especially the code snippets, you'll find lots of useful info, maybe even complete scripts. See for example
viewtopic.php?t=38119 for an upload image script. Search some more for more examples, look for a user authentication script, combine the two and you're half way done, I hope

Posted: Thu Jan 19, 2006 8:19 am
by Circle
Thanks but I'm working on some other script I got from a website and will make changes to that first hopefully that will learn me more about what I'm doing. I will post a new topic for questions about it.