bryanptcs Posted December 15, 2006 Share Posted December 15, 2006 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.htmlThank you.[attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/30787-upload-to-directory-based-on-business-name/ Share on other sites More sharing options...
timmah1 Posted December 15, 2006 Share Posted December 15, 2006 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] Link to comment https://forums.phpfreaks.com/topic/30787-upload-to-directory-based-on-business-name/#findComment-141935 Share on other sites More sharing options...
complex05 Posted December 15, 2006 Share Posted December 15, 2006 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. Link to comment https://forums.phpfreaks.com/topic/30787-upload-to-directory-based-on-business-name/#findComment-141937 Share on other sites More sharing options...
bryanptcs Posted December 15, 2006 Author Share Posted December 15, 2006 [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? Link to comment https://forums.phpfreaks.com/topic/30787-upload-to-directory-based-on-business-name/#findComment-141950 Share on other sites More sharing options...
complex05 Posted December 15, 2006 Share Posted December 15, 2006 repost your PHP script as an attachment with the modification u just made. Link to comment https://forums.phpfreaks.com/topic/30787-upload-to-directory-based-on-business-name/#findComment-141956 Share on other sites More sharing options...
bryanptcs Posted December 15, 2006 Author Share Posted December 15, 2006 here it is[attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/30787-upload-to-directory-based-on-business-name/#findComment-141963 Share on other sites More sharing options...
complex05 Posted December 15, 2006 Share Posted December 15, 2006 hehe, you have <input type="hidden" name="$upload_dir">it should be <input type="hidden" name="upload_dir" value="$upload_dir">That will work :) Link to comment https://forums.phpfreaks.com/topic/30787-upload-to-directory-based-on-business-name/#findComment-141969 Share on other sites More sharing options...
bryanptcs Posted December 15, 2006 Author Share Posted December 15, 2006 it still lost it Link to comment https://forums.phpfreaks.com/topic/30787-upload-to-directory-based-on-business-name/#findComment-141981 Share on other sites More sharing options...
complex05 Posted December 15, 2006 Share Posted December 15, 2006 please repost :) Link to comment https://forums.phpfreaks.com/topic/30787-upload-to-directory-based-on-business-name/#findComment-141986 Share on other sites More sharing options...
bryanptcs Posted December 15, 2006 Author Share Posted December 15, 2006 here is is[attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/30787-upload-to-directory-based-on-business-name/#findComment-141992 Share on other sites More sharing options...
complex05 Posted December 15, 2006 Share Posted December 15, 2006 Now you need to use $_POST['upload_dir'] unless you have register_globals on. Link to comment https://forums.phpfreaks.com/topic/30787-upload-to-directory-based-on-business-name/#findComment-141993 Share on other sites More sharing options...
bryanptcs Posted December 15, 2006 Author Share Posted December 15, 2006 where do I need to place that? Link to comment https://forums.phpfreaks.com/topic/30787-upload-to-directory-based-on-business-name/#findComment-142007 Share on other sites More sharing options...
complex05 Posted December 15, 2006 Share Posted December 15, 2006 EVERYWHERE :) Link to comment https://forums.phpfreaks.com/topic/30787-upload-to-directory-based-on-business-name/#findComment-142036 Share on other sites More sharing options...
bryanptcs Posted December 15, 2006 Author Share Posted December 15, 2006 register_globals was already set to on... Link to comment https://forums.phpfreaks.com/topic/30787-upload-to-directory-based-on-business-name/#findComment-142059 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.