Uploading?

Czukoman20
Czukoman20 used Ask the Experts™
on
I have this upload script that I am currently modifying a little bit. I need to be able to make it so that the dumbest of the dumb can figure this thing out. The upload bar requires specific sizes and sometimes the user wont even have a logo to upload. So what I would like to do is make it so if the user clicks a certain javascript button that says. "Don't Have a Logo Click Here, Then Click Upload.?" it will prefill the box with a blank logo located on the site (so a site directory).

The code below is the upload bar(not the upload code). I am unfamiliar with javascript, so thats where I need the help.

Thanks in Advance!


<table width="500" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="">
                <tr>
<form action="upload_rename_ac.php?u=<? 
echo "$user";
?>" method="post" enctype="multipart/form-data" name="form1" id="form1">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="">
<tr>
<td><strong>Single File Upload </strong></td>
</tr>
<tr>
<td>Select file
<input name="ufile" type="file"  id="ufile" size="50" /></td>
</tr>
<tr>
<td align="center"><input type="submit" name="Submit" value="Upload" /></td>
</tr>
</table>
</td>
</form>
</tr>
</table>

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
This may not be exactly what you want, but (to me) it is simpler.

Add this (its in the code snipet incorporated into your example)

<tr>
<td align="center"><input type=submit name="Submit" value=""></td>
</tr>


Then in your php:
if ($_POST['Submit'] == "Upload") {
// do your upload stuff
}
if ($_POST['Submit'] == "Don't Have a Logo Click Here") {
// do your default logo
}

This also solves the problem that the browser won't be able to upload a "default" file that exists on your server, because it doesn't exist on the client's pc.

<table width="500" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="">
                <tr>
<form action="upload_rename_ac.php?u=<? 
echo "$user";
?>" method="post" enctype="multipart/form-data" name="form1" id="form1">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="">
<tr>
<td><strong>Single File Upload </strong></td>
</tr>
<tr>
<td>Select file
<input name="ufile" type="file"  id="ufile" size="50" /></td>
</tr>
<tr>
<td align="center"><input type="submit" name="Submit" value="Upload" /></td>
</tr>
<tr>
<td align="center"><input type=submit name="Submit" value="Don't Have a Logo Click Here"></td>
</tr>
</table>
</td>
</form>
 
</tr>
</table>

Open in new window

Commented:
When you say prefill a box, are you talking about the file input?  If so, can't be done, its a security risk.  You can't assign values to file inputs.

I guess, really, I'm unsure what you mean by the "box" to prefill.  (Or maybe I am missing the point of the question?)

Author

Commented:
Ahh .. I c thats why it wont show up when I add a value to it. Thats cool then. I'm gonna have to figure out a way around it.

Thanks!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial