Jump to content

upload to directory based on business name....


bryanptcs

Recommended Posts

Ok, here is what I need my code to do....

My client visits the site, fills out an HTML form with thier company info and they hit submit...

On submit, the php code is run which stores the data to the DB,  creates a directory (name follows the business field), and echo's the next form which will alow the client to browse for the files they wish to upload.  On submit, the code should then determine if the file is acceptable, if it is it should upload the files to the directory that was just created. 

I am able to get everything going up until the upload part.  When the directory is created I define it as a constant.  However in the upload stage that constant is lost an it just tries to upload the file to base directory.  The code is about 150 lines of code, and so I could not post it.  I have attached the HTML code and the php code (the php code is the zip file)....if you want to take a look at it working/not working, please visit palmtreemobilebillboards.com/test.html

Thank you.

[attachment deleted by admin]
When I hit the submit button at http://palmtreemobilebillboards.com/test.html, I get this
[code]
artwork/teeststtst<hr> <p class="smalltext">Please fill out all fields and select up to 5 files to upload.  If needed you may re-submit another form in order to upload more files Your files will be uploaded to artwork/teeststtst.<br>
          Max file size = 50 KB</p> <form method="post" action="/test5.php" enctype="multipart/form-data"><table width="280" border="0" align="center"><tr><td><span class="smalltext">File 1: <input type="file" name="file1"><br><span class="smalltext">File 2: <input type="file" name="file2"><br><span class="smalltext">File 3: <input type="file" name="file3"><br><span class="smalltext">File 4: <input type="file" name="file4"><br><span class="smalltext">File 5: <input type="file" name="file5"><br> <input type="hidden" name="MAX_FILE_SIZE" value="51200"></span>
          <input type="submit" name="upload_form" value="Upload and Submit">
          </form></td></tr></table>
[/code]
Hi, I see in your code you are using the define() function. Instead of using define, just use a variable for the directory name. Then on your form, do a hidden field with the directory name, or use a session. This way, the directory name will not be lost.
[quote author=complex05 link=topic=118777.msg485640#msg485640 date=1166212014]
Hi, I see in your code you are using the define() function. Instead of using define, just use a variable for the directory name. Then on your form, do a hidden field with the directory name, or use a session. This way, the directory name will not be lost.
[/quote]

I took the define out, and just called it by the variable $upload_dir.

I replaced lines 129-132 with the following:

[code]
  echo " <input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"$size_bytes\"></span>
      <input type=\"hidden\" name=\"$upload_dir\">
          <input type=\"submit\" name=\"upload_form\" value=\"Upload and Submit\">
          </form>";
[/code]

It is still loosing the directory variable...did I do it right?

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.