duanju8431 2015-12-10 07:47
浏览 63
已采纳

ASP / PHP&Access mdb文件/图像文件路径

--- Revised with detail because of helpful pertaining comments ---

Essential I just want to upload one or multiple image files into a folder while saving its file path information onto a MDB file, so in that way I can open the image onto the webpage through the saved file path.

From what I understand from my own research and from comments from others on this thread is that there is several ways to do this.

1 - I could just solely use ASP to upload the image file into a folder and save its file path into a record within a recordset in a MDB file.

This option would be great but also more time consuming cause I would need to figure out what code to use to send the image file to a specific folder, to take the file path information and write it to a MDB recordset record, and to provide similar security in how I currently have the PHP code setup in defining if its a actual image file or not.

2 - I could also use PHP to upload the image file into a folder (already have the code for) and also use PHP to write the file path to the MDB file. (don't have the code for)

This option would be best since I have the upload file to folder portion of it done. Yet I'm not sure how to send its file path information directly from PHP to the MDB file, plus the other concern would be on how to utilize the user session with it.

3 - Lastly, there might be a way to take the info from the PHP variable and send it to a ASP variable and then from there I can write the file path into the MDB file.

The last option which is the shortest route because I already have the PHP portion of upload file to folder done and I already know how to write to the MDB file using ASP. Problem is, how do I pass the variable information from the PHP portion to the ASP portion

Basically from the paragraph above, that'll require figuring out how to take the upload file path info from the $target_file :example - ../uploads/image.jpg

Then placing that info into one or a array ASP variable for one or several records in a recordset, since the current upload php code allows for one or more image uploads.

As is what I'm currently using is HTML and PHP to upload image files and I plan on using ASP with the page, however passing the PHP variable to the ASP variable is what I'm stuck on. I know its possible to pass info from one code to another like how you can use Ajax to pass info from JS to PHP, just not sure how to do that with PHP to ASP.

Below is the current code in the HTML file

<form action="php/upload.php" method="post" enctype="multipart/form-data">
  <label for="filesToUpload" style="margin-top:10px">Select Images to Upload</label><br>
  <input type="file" name="filesToUpload[]" id="filesToUpload" multiple="multiple" style="display:inline-block">
  <output id="filesInfo" style="display:inline-block"></output>
  <i class="fa fa-photo fa-fw"></i>&nbsp;<input type="submit" value="Upload Image(s)" style="margin-top:5px" name="submit"><br><br>
</form>

As for the PHP code, I would love to show all of it on here but its giving me issues to add it onto here, so I'll show the meat of it and leave out the security portion of it.

for($i=0; $i < count($_FILES['filesToUpload']['name']); $i++){
$target_dir = "../uploads/";
$target_file = $target_dir . basename($_FILES['filesToUpload']['name'][$i]);
$uploadOk = 1;

if ($uploadOk == 0) {
    echo "Sorry, your file was not uploaded. ";
} else {
if (move_uploaded_file($_FILES["filesToUpload"]["tmp_name"][$i], $target_file)) {
        echo "The file ". basename( $_FILES["filesToUpload"]["name"][$i]). " has been uploaded. ";
    } else {
        echo "Sorry, there was an error uploading your file. ";
    }
}
}

I also know that I could use a ASP variable that might be stated as:

Dim imagePath
imagePath = 

But that's where I get stuck on how to apply the content from the PHP $target_file variable to the ASP imagePath variable.

  • 写回答

1条回答 默认 最新

  • dousao6313 2015-12-14 19:04
    关注

    Thank you to those that tried to help but I was able to find the answer to my question, so I decided to share the solution.

    I went with option one -

    1 - I could just solely use ASP to upload the image file into a folder and save its file path into a record within a recordset in a MDB file.

    This option would be great but also more time consuming cause I would need to figure out what code to use to send the image file to a specific folder, to take the file path information and write it to a MDB recordset record, and to provide similar security in how I currently have the PHP code setup in defining if its a actual image file or not.

    I went with that option because I found a simple, easy and cost effective solution in the following link: http://planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=8525&lngWId=4

    The content in the above link provides what I was looking for and much more, plus its easy to integrate. It also has sample scripts to work with as well.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改